Code Snippet - How to Find Items by ObjectId with Mongoose

2014/7/51 min read
bookmark this
Responsive image

Get all records where the Ids contains specfic object Id.

  var q= yourCollection.find({ Ids: mongoose.Types.ObjectId('539ba44481973asdfe0c402bc6') });
    q.exec(function (err, items)
    {
        console.info(err);
        console.info(items.length);
    });