I have populated a virtual in Mongoose, the populated virtual will retrieve an array of objects.
objects:{[name:'xxx',age:20],[name:'yyy',age:21],[name:'zzz', age:23]}
How do I make it that it only retrieves one element I specify?
...
.populate({
path:'someVirtual',
select:'objects', //get only the 'objects' array
options: {where:'objects',elemMatch:{name:'zzz'}} //this is what I tried
//but it doesn't work
)}
.exec(function(err,docs){
//handle
});