How to get a specific object from an array field with mongoose [duplicate] How to get a specific object from an array field with mongoose [duplicate] mongoose mongoose

How to get a specific object from an array field with mongoose [duplicate]


This is pretty similar to the possible duplicate I linked to, as you can do this without using lodash as:

User.findOne({  _id: userId,  'donations.charity': charityId}, {  'donations.$': 1}, function(err, user) {  console.log("the amount is: ", user.donations[0].amount);});