db.auth() | If running in secure mode, authenticate the user. |
coll = db.<collection> | Set a specific collection in the current database to a variable coll, as in the following example:copycopiedcoll = db.myCollection; You can perform operations on the myCollection using the variable, as in the following example:copycopiedcoll.find(); |
db.collection.find() | Find all documents in the collection and returns a cursor.See the db.collection.find() and Query Documents for more information and examples.See Iterate a Cursor in the mongo Shell for information on cursor handling in the mongo shell. |
db.collection.insertOne() | Insert a new document into the collection. |
db.collection.insertMany() | Insert multiple new documents into the collection. |
db.collection.updateOne() | Update a single existing document in the collection. |
db.collection.updateMany() | Update multiple existing documents in the collection. |
db.collection.save() | Insert either a new document or update an existing document in the collection. |
db.collection.deleteOne() | Delete a single document from the collection. |
db.collection.deleteMany() | Delete documents from the collection. |
db.collection.drop() | Drops or removes completely the collection. |
db.collection.createIndex() | Create a new index on the collection if the index does not exist; otherwise, the operation has no effect. |
db.getSiblingDB() | Return a reference to another database using this same connection without explicitly switching the current database. This allows for cross database queries. |