node.js - Limit fields in MongoDB response -


i doing join using $lookup, i'm getting field, including not required, need restrict it.

here query

exports.query = function (req, res) {     questionlist.aggregate([{                 $match : {                     topicname : req.query.topicname                 }             }, {                 $lookup : {                     : "questions",                     localfield : "queslist.queslistname",                     foreignfield : "queslistname",                     : "queslistcount"                 }             }         ], {         queslist : 0     }, function (err, questionlist) {         console.log(questionlist);         if (err) {             return handleerror(res, err);         }         return res.status(200).json(fndata(questionlist));     }); }; 

the response getting

{     _id : "57453e45a11c97483f97a4c9",     queslist : {         : "swathi",         queslistname : "controller question list",         queslistcount : [{                 queslistname : "controller question list",                 question : "what controller function?"             }         ]     },  } 

here need restrict queslistname in queslistcount array .


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -