All command documentation lined below describes the commands and available parameters, provides a document template or prototype for each command. Some command documentation also includes the relevant mongo.
| Name | Description |
|---|---|
| aggregate | Performs aggregation tasks such as group using the aggregation framework. |
| count | Counts the number of documents in a collection. |
| distinct | Displays the distinct values found for a specified key in a collection. |
| group | Groups documents in a collection by the specified key and performs simple aggregation. |
| mapReduce | Performs map-reduce aggregation for large data sets. |
| Name | Description |
|---|---|
| geoNear | Performs a geospatial query that returns the 100 documents closest to a given point. |
| geoSearch | Performs a geospatial query that uses MongoDB’s haystack index functionality. |
| geoWalk | An internal command to support geospatial queries. |
| Name | Description |
|---|---|
| eval | Runs a JavaScript function on the database server. |
| findAndModify | Returns and modifies a single document. |
| getLastError | Returns the success status of the last operation. |
| getPrevError | Returns status document containing all errors since the last resetError command. |
| resetError | Resets the last error status. |
| text | Performs a text search. |
| Name | Description |
|---|---|
| applyOps | Internal command that applies oplog entries to the current data set. |
| getoptime | Internal command to support replication, returns the optime. |
| isMaster | Displays information about this member’s role in the replica set, including whether it is the master. |
| replSetFreeze | Prevents the current member from seeking election as primary for a period of time. |
| replSetGetStatus | Returns a document that reports on the status of the replica set. |
| replSetInitiate | Initializes a new replica set. |
| replSetMaintenance | Enables or disables a maintenance mode, which puts a secondary node in a RECOVERING state. |
| replSetReconfig | Applies a new configuration to an existing replica set. |
| replSetStepDown | Forces the current primary to step down and become a secondary, forcing an election. |
| replSetSyncFrom | Explicitly override the default logic for selecting a member to replicate from. |
| resync | Forces a mongod to re-synchronize from the master. For master-slave replication only. |
See also
“Replica Set Fundamental Concepts” for more information regarding replication.
| Name | Description |
|---|---|
| addShard | Adds a shard to a sharded cluster. |
| checkShardingIndex | Internal command that validates index on shard key. |
| enableSharding | Enables sharding on a specific database. |
| flushRouterConfig | Forces an update to the cluster metadata cached by a mongos. |
| getShardMap | Internal command that reports on the state of a sharded cluster. |
| getShardVersion | Internal command that returns the config server version. |
| isdbgrid | Verifies that a process is a mongos. |
| listShards | Returns a list of configured shards. |
| medianKey | Deprecated internal command. See splitVector. |
| moveChunk | Internal command that migrates chunks between shards. |
| movePrimary | Reassigns the primary shard when removing a shard from a sharded cluster. |
| removeShard | Starts the process of removing a shard from a sharded cluster. |
| setShardVersion | Internal command to sets the config server version. |
| shardCollection | Enables the sharding functionality for a collection, allowing the collection to be sharded. |
| shardingState | Reports whether the mongod is a member of a sharded cluster. |
| splitChunk | Internal command to split chunk. Instead use the methods sh.splitFind() and sh.splitAt(). |
| splitVector | Internal command that determines split points. |
| split | Creates a new chunk. |
| unsetSharding | Internal command that affects connections between instances in a MongoDB deployment. |
See also
Sharding for more information about MongoDB’s sharding functionality.
| Name | Description |
|---|---|
| clean | Internal namespace administration command. |
| cloneCollectionAsCapped | Copies a non-capped collection as a new capped collection. |
| cloneCollection | Copies a collection from a remote host to the current host. |
| clone | Copies a database from a remote host to the current host. |
| closeAllDatabases | Internal command that invalidates all cursors and closes open database files. |
| collMod | Add flags to collection to modify the behavior of MongoDB. |
| compact | Defragments a collection and rebuilds the indexes. |
| connPoolSync | Internal command to flush connection pool. |
| convertToCapped | Converts a non-capped collection to a capped collection. |
| copydb | Copies a database from a remote host to the current host. |
| create | Creates a collection and sets collection parameters. |
| dropDatabase | Removes the current database. |
| dropIndexes | Removes indexes from a collection. |
| drop | Removes the specified collection from the database. |
| filemd5 | Returns the md5 hash for files stored using GridFS. |
| fsync | Flushes pending writes to the storage layer and locks the database to allow backups. |
| getParameter | Retrieves configuration options. |
| logRotate | Rotates the MongoDB logs to prevent a single file from taking too much space. |
| reIndex | Rebuilds all indexes on a collection. |
| renameCollection | Changes the name of an existing collection. |
| repairDatabase | Repairs any errors and inconsistencies with the data storage. |
| setParameter | Modifies configuration options. |
| shutdown | Shuts down the mongod or mongos process. |
| touch | Loads documents and indexes from data storage to memory. |
| Name | Description |
|---|---|
| availableQueryOptions | Internal command that reports on the capabilities of the current MongoDB instance. |
| buildInfo | Displays statistics about the MongoDB build. |
| collStats | Reports storage utilization statics for a specified collection. |
| connPoolStats | Reports statistics on the outgoing connections from this MongoDB instance to other MongoDB instances in the deployment. |
| cursorInfo | Reports statistics on active cursors. |
| dataSize | Returns the data size for a range of data. For internal use. |
| dbHash | Internal command to support sharding. |
| dbStats | Reports storage utilization statistics for the specified database. |
| diagLogging | Provides a diagnostic logging. For internal use. |
| driverOIDTest | Internal command that converts an ObjectID to a string to support tests. |
| features | Reports on features available in the current MongoDB instance. |
| getCmdLineOpts | Returns a document with the run-time arguments to the MongoDB instance and their parsed options. |
| getLog | Returns recent log messages. |
| hostInfo | Returns data that reflects the underlying host system. |
| indexStats | Experimental command that collects and aggregates statistics on all indexes. |
| isSelf | Internal command to support testing. |
| listCommands | Lists all database commands provided by the current mongod instance. |
| listDatabases | Returns a document that lists all databases and returns basic database statistics. |
| netstat | Internal command that reports on intra-deployment connectivity. Only available for mongos instances. |
| ping | Internal command that tests intra-deployment connectivity. |
| profile | Interface for the database profiler. |
| serverStatus | Returns a collection metrics on instance-wide resource utilization and status. |
| top | Returns raw usage statistics for each database in the mongod instance. |
| validate | Internal command that scans for a collection’s data and indexes for correctness. |
| whatsmyuri | Internal command that returns information on the current client. |
| Name | Description |
|---|---|
| _migrateClone | Internal command that supports chunk migration. Do not call directly. |
| _recvChunkAbort | Internal command that supports chunk migrations in sharded clusters. Do not call directly. |
| _recvChunkCommit | Internal command that supports chunk migrations in sharded clusters. Do not call directly. |
| _recvChunkStart | Internal command that facilitates chunk migrations in sharded clusters.. Do not call directly. |
| _recvChunkStatus | Internal command that returns data to support chunk migrations in sharded clusters. Do not call directly. |
| _replSetFresh | Internal command that supports replica set election operations. |
| _transferMods | Internal command that supports chunk migrations. Do not call directly. |
| handshake | Internal command. |
| mapreduce.shardedfinish | Internal command that supports map-reduce in sharded cluster environments. |
| replSetElect | Internal command that supports replica set functionality. |
| replSetGetRBID | Internal command that supports replica set operations. |
| replSetHeartbeat | Internal command that supports replica set operations. |
| writeBacksQueued | Internal command that supports chunk migrations in sharded clusters. |
| writebacklisten | Internal command that supports chunk migrations in sharded clusters. |
| Name | Description |
|---|---|
| _hashBSONElement | Internal command. Computes the MD5 hash of a BSON element. |
| _journalLatencyTest | Tests the time required to write and perform a file system sync for a file in the journal directory. |
| captrunc | Internal command. Truncates capped collections. |
| configureFailPoint | Internal command for testing. Configures failure points. |
| emptycapped | Internal command. Removes all documents from a capped collection. |
| forceerror | Internal command for testing. Forces a user assertion exception. |
| godinsert | Internal command for testing. |
| replSetTest | Internal command for testing replica set functionality. |
| skewClockCommand | Internal command. Do not call this command directly. |
| sleep | Internal command for testing. Forces MongoDB to block all operations. |
| testDistLockWithSkew | Internal command. Do not call this directly. |
| testDistLockWithSyncCluster | Internal command. Do not call this directly. |