To select where in array of _id with MongoDB and JavaScript, we call the find
method.
For instance, we write
db.collection.find({ _id: { $in: [ObjectId("1"), ObjectId("2")] } });
to call find
with an object with the _id
property set to an array with the object IDs to look for in the collection
.