Here are some of the most common MongoDB commands for databases:
- db.createDatabase(name): Creates a new database with the given name.
- db.dropDatabase(name): Drops the database with the given name.
- db.listDatabases(): Lists all the databases in the current MongoDB instance.
- db.getCollectionNames(): Lists all the collections in the current database.
- db.collection.createIndex(key, options): Creates an index on the given collection.
- db.collection.dropIndex(key): Drops the index with the given key from the given collection.
- db.collection.find(query, projection): Performs a query on the given collection and returns the results.
- db.collection.insertOne(document): Inserts a new document into the given collection.
- db.collection.insertMany(documents): Inserts multiple documents into the given collection.
- db.collection.updateOne(query, update): Updates a document in the given collection.
- db.collection.updateMany(query, update): Updates multiple documents in the given collection.
- db.collection.deleteOne(query): Deletes a document from the given collection.
- db.collection.deleteMany(query): Deletes multiple documents from the given collection.
These are just a few of the many MongoDB commands that you can use to manage your databases. For more information, please refer to the MongoDB documentation: https://www.mongodb.com/docs/manual/reference/command/.
Here are some additional commands that you may find useful:
- db.help(): Lists all the MongoDB commands.
- db.currentOp(): Shows the current operations running in the database.
- db.stats(): Shows statistics about the database.
- db.repairDatabase(): Repairs the database.
- db.fsync(): Forces the database to flush to disk.
I hope this helps! Let me know if you have any other questions.