Docs Menu
Docs Home
/
MongoDB Manual
/ /

Database Methods

Note

For details on a specific method, including syntax and examples, click on the link to the method's reference page.

Name
Description
db.adminCommand()
Runs a command against the admin database.
Runs admin/diagnostic pipeline which does not require an underlying collection.
Returns help information for a database command.
Creates a new collection or a view. Commonly used to create a capped collection.
Creates a view.
Reports the current in-progress operations.
Removes the current database.
Flushes writes to disk and locks the database to prevent write operations and assist backup operations. Wraps fsync.
Allows writes to continue on a database locked with db.fsyncLock().
Returns a collection or view object. Used to access collections with names that are not valid in mongosh.
Returns collection information for all collections and views in the current database.
Lists all collections and views in the current database.
Returns the log message verbosity levels.
Returns the Mongo() connection object for the current connection.
Returns the name of the current database.
Returns a document that reflects the current profiling level and the profiling threshold.
Returns a document with replication statistics.
Provides access to the specified database.
Returns a document that reports the state of the replica set.
Displays descriptions of common db object methods.
Returns a document with information about the system MongoDB runs on. Wraps hostInfo
Terminates a specified operation.
Displays a list of common database commands.
Deprecated. Ends an authenticated session.
Prints statistics from every collection. Wraps db.collection.stats().
Prints a formatted report of the replica set status from the perspective of the primary.
Prints a formatted report of the replica set status from the perspective of the secondaries.
Prints a report of the sharding configuration and the chunk ranges.

Deprecated since version 4.4.1: Use db.printSecondaryReplicationInfo() instead.

Removed in MongoDB 5.0. Resets the last error status.
Performs online TLS certificate rotation. Wraps rotateCertificates.
Returns a document that displays the compilation parameters for the mongod instance. Wraps buildInfo.
Returns a document with information about the runtime used to start the MongoDB instance. Wraps getCmdLineOpts.
Returns a document that provides an overview of the state of the database process.
Sets a single log message verbosity level.
Modifies the current level of database profiling.
Shuts down the current mongod or mongos process cleanly and safely.
Returns a document that reports on the state of the current database.
Returns the version of the mongod instance.
Opens a change stream cursor for a database to report on all its non-system collections. Cannot be opened on the admin, local or config databases.

Back

cursor.tryNext()