How do I perform an id array query in Mongoose?
Here is a mongoosey way to use the $in operator.
User.find()
.where('fb.id')
.in([3225, 623423, 6645345])
.exec(function (err, records) {
//make magic happen
});
I find the dot notation quite handy for querying into sub documents.
http://mongoosejs.com/docs/queries.html
You need to use the $in operator >
https://docs.mongodb.com/manual/reference/operator/query/in/#op._S_in
For example:
Users.find( { "fb" : { id: { $in : arrayOfIds } } }, callback );
User.where({ records: { $in: [3225, 623423, 6645345] } }, function ...
more info here: http://docs.mongodb.org/manual/reference/operator/query/