Monday, 4 January 2021

$project in MogooDb/Mongoose

SubscribeMentor // .find({ subscriberId: req.query.subscriberId }) .aggregate([ { "$addFields": { "mentorId": { "$toObjectId": "$mentorId" } } }, { "$match": { "subscriberId": req.query.subscriberId } }, { "$lookup": { "from": "mentors", "foreignField": "_id", "localField": "mentorId", "as": "mentor" } }, { "$project": { "subscriberId": 1, "mentorId": 1, "mentor": { name: 1, email: 1, status: 1 } } } ]) .then(mymenotrs => { res.send({ myMentors: mymenotrs }); }).catch(err => { res.status(500).send({ Message: err.message, Result: false, data: err }); })

No comments:

Post a Comment

IIS deployment support details

  Node JS - IIS deployment support details node: http://go.microsoft.com/?linkid=9784334 IISNode: https://github.com/azure/iisnode/releases/...