Code Snippet - How to Find Items by ObjectId with Mongoose

7/5/2014·1 min read
Responsive image
Photo by True Agency on Unsplash

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);
    });