Sometimes, we want to select where in array of _id with MongoDB.
In this article, we’ll look at how to select where in array of _id with MongoDB.
How to select where in array of _id with MongoDB?
To select where in array of _id with MongoDB, we can use the find
method with the $in
operator property.
For instance, we write
db.collection.find({ _id: { $in: [1, 2, 3, 4] } });
to call find
with the _id.$in
property set to an array of ID’s we’re looking for in the collection.
Conclusion
To select where in array of _id with MongoDB, we can use the find
method with the $in
operator property.