Answers for "mongodb get multiple documents by id"

0

mongodb get multiple documents by id

# For one record only
db.getCollection('collection_name').find(
  {
    "_id": ObjectId("55880c251df42d0466919268")
  }
);

# For multiple records
db.getCollection('collection_name').find(
  {
    "_id" : {
      "$in" : [
        ObjectId("55880c251df42d0466919268"), 
        ObjectId("55bf528e69b70ae79be35006")
      ]
    }
  }
);
Posted by: Guest on July-27-2021

Code answers related to "mongodb get multiple documents by id"

Browse Popular Code Answers by Language