Mongoose select on sub document
I have this Mongoose Schema:
UserSchema = new db.Schema({
fullname : String,
sale : [{ _id: [db.Schema.Types.ObjectId] }],
friends : [db.Schema.Types.ObjectId]
}
how can I fix this code to make it select the _id field of Sale? TIA
user.Model
.find({
_id : {
$in: friends
}
})
.select('sale._id') // invalid syntax
.exec(function(err, results) {
console.log(results);
});
No comments:
Post a Comment