MongoDB List of Commands
S:slave-ok R:read-lock W:write-lock A:admin-only| Command | Attributes | Help |
|---|---|---|
| _isSelf | S | { _isSelf : 1 } INTERNAL ONLY |
| _migrateClone | A | internal - should not be called directly |
| _recvChunkAbort | A | internal - should not be called directly |
| _recvChunkCommit | A | internal - should not be called directly |
| _recvChunkStart | W A | internal - should not be called directly |
| _recvChunkStatus | A | internal - should not be called directly |
| _testDistLockWithSyncCluster | A | should not be calling this directly |
| _transferMods | A | internal - should not be called directly |
| applyOps | W | examples: { applyOps : [ ] , preCondition : [ |
| authenticate | W S | internal |
| availableQueryOptions | S | |
| buildInfo | S A | get version #, etc.{ buildinfo:1 } |
| captrunc | W | |
| checkShardingIndex | R | Internal command. |
| clean | W S | internal |
| clone | W | clone this database from an instance of the db on another host{ clone : "host13" } |
| cloneCollection | { cloneCollection: <namespace>, from: <host> [,query: <query_filter>] [,copyIndexes:<bool>] }Copies a collection from one server to another. Do not use on a single server as the destination is placed at the same db.collection (namespace) as the source. Warning: the local copy of 'ns' is emptied before the copying begins. Any existing data will be lost there. | |
| cloneCollectionAsCapped | W | { cloneCollectionAsCapped:<fromName>, toCollection:<toName>, size:<sizeInBytes> } |
| closeAllDatabases | W A | Close all database files. A new request will cause an immediate reopening; thus, this is mostly for testing purposes. |
| collStats | R S | { collStats:"blog.posts" , scale : 1 } scale divides sizes e.g. for KB use 1024 |
| connPoolStats | S | stats about connection pool |
| connPoolSync | S | internal |
| convertToCapped | W | { convertToCapped:<fromCollectionName>, size:<sizeInBytes> } |
| copydb | W A | copy a database from another host to this host usage: {copydb: 1, fromhost: <hostname>, fromdb: <db>, todb: <db>[, username: <username>, nonce: <nonce>, key: <key>]} |
| copydbgetnonce | W A | get a nonce for subsequent copy db request from secure server usage: {copydbgetnonce: 1, fromhost: <hostname>} |
| count | R | count objects in collection |
| create | W | create a collection |
| cursorInfo | S | example: { cursorInfo : 1 } |
| dataSize | R S | determine data size for a set of data in a certain range example: { dataSize:"blog.posts", keyPattern:keyPattern, min, and max parameters are optional. note: This command may take a while to run |
| dbHash | R S | |
| dbStats | R S | example: { dbStats:1 } |
| diagLogging | W S A | DOCS/Monitoring and Diagnostics |
| distinct | R S | { distinct : 'collection name' , key : 'a.b' , query : |
| driverOIDTest | S | |
| drop | W | drop a collection{drop : <collectionName>} |
| dropDatabase | W | drop (delete) this database |
| dropIndexes | W | drop indexes for a collection |
| emptycapped | W | |
| eval | Evaluate javascript at the server. DOCS/Server-side Code Execution | |
| features | S | return build level feature settings |
| filemd5 | R S | example: { filemd5 : ObjectId(aaaaaaa) , root : "fs" } |
| findAndModify | W | { findAndModify: "collection", query: { findAndModify: "collection", query: Either update or remove is required, all other fields have default values. Output is in the "value" field |
| forcedead | W S A | internal |
| forceerror | S | for testing purposes only. forces a user assertion exception |
| fsync | W S A | DOCS/fsync Command |
| geoNear | R S | DOCS/Geospatial Indexing |
| geoSearch | R S | |
| geoWalk | R S | |
| getCmdLineOpts | S A | get argv |
| getLastError | S | return error status of the last operation on this connection options: fsync - fsync before returning, or wait for journal commit if running with --dur w - await replication to w servers (including self) before returning wtimeout - timeout for w in milliseconds |
| getParameter | S A | get administrative option(s) example: { getParameter:1, notablescan:1 }supported so far: quiet notablescan logLevel syncdelay { getParameter:'*' } to get everything |
| getPrevError | S | check for errors since last reseterror commandcal |
| getShardMap | S A | internal |
| getShardVersion | A | example: { getShardVersion : 'alleyinsider.foo' } |
| getnonce | S | internal |
| getoptime | S | internal |
| godinsert | W | internal. for testing only. |
| group | R | DOCS/Aggregation |
| handshake | S | internal |
| isMaster | S | Check if this server is primary for a replica pair/set; also if it is --master or --slave in simple master/slave setups.{ isMaster : 1 } |
| isinitialsynccomplete | S | |
| journalLatencyTest | S A | test how long to write and fsync to a test file in the journal/ directory |
| listCommands | S | get a list of all db commands |
| listDatabases | R S A | list databases on this server |
| logRotate | S A | |
| logout | S | de-authenticate |
| mapReduce | Run a map/reduce operation on the server. Note this is used for aggregation, not querying, in MongoDB. DOCS/MapReduce | |
| mapreduce.shardedfinish | ||
| medianKey | R S | Internal command. example: { medianKey:"blog.posts", keyPattern:NOTE: This command may take a while to run |
| moveChunk | A | should not be calling this directly |
| negotiatemaster | W S A | |
| ping | S | a way to check that the server is alive. responds immediately even if server is in a db lock. |
| profile | W S | enable or disable performance profiling{ profile : <n> }0=off 1=log slow ops 2=log all -1 to get current values DOCS/Database Profiler |
| reIndex | W S | re-index a collection |
| renameCollection | W A | example: { renameCollection: foo.a, to: bar.b } |
| repairDatabase | W S | repair database. also compacts. note: slow. |
| replSetElect | S A | internal |
| replSetFreeze | S A | { replSetFreeze : <seconds> }'freeze' state of member to the extent we can do that. What this really means is thatthis node will not attempt to become primary until the time period specified expires. You can call again with {replSetFreeze:0} to unfreeze sooner.A process restart unfreezes the member also. DOCS/Replica Set Commands |
| replSetFresh | S A | internal |
| replSetGetRBID | S A | internal |
| replSetGetStatus | S A | Report status of a replica set from the POV of this server{ replSetGetStatus : 1 }DOCS/Replica Set Commands |
| replSetHeartbeat | S | internal |
| replSetInitiate | S A | Initiate/christen a replica set. DOCS/Replica Set Commands |
| replSetReconfig | S A | Adjust configuration of a replica set{ replSetReconfig : config_object }DOCS/Replica Set Commands |
| replSetStepDown | S A | { replSetStepDown : <seconds> }Step down as primary. Will not try to reelect self for the specified time period (1 minute if no numeric secs value specified). (If another member with same priority takes over in the meantime, it will stay primary.) DOCS/Replica Set Commands |
| replSetTest | S A | Just for regression tests. |
| replacePeer | W S A | replace a node in a replica pair |
| resetError | S | reset error state (used with getpreverror) |
| resync | W S A | resync (from scratch) an out of date replica slave. DOCS/Master Slave |
| serverStatus | S | returns lots of administrative server statistics |
| setParameter | S A | set administrative option(s) example: { setParameter:1, notablescan:true }supported so far: notablescan logLevel quiet |
| setShardVersion | A | example: { setShardVersion : 'alleyinsider.foo' , version : 1 , configdb : '' } |
| shardingState | W A | |
| shutdown | S A | shutdown the database. must be ran against admin db and either (1) ran from localhost or (2) authenticated. |
| sleep | S A | internal testing command. Makes db block (in a read lock) for 100 seconds w:true write lock |
| splitChunk | A | internal command usage only example: { splitChunk:"db.foo" , keyPattern: |
| splitVector | R | Internal command. examples: { splitVector : "blog.post" , keyPattern:maxChunkSize unit in MBs May optionally specify 'maxSplitPoints' and 'maxChunkObjects' to avoid traversing the whole chunk { splitVector : "blog.post" , keyPattern:'force' will produce one split point even if data is small; defaults to false NOTE: This command may take a while to run |
| top | R S A | usage by collection |
| unsetSharding | S A | example: { unsetSharding : 1 } |
| validate | R S | Validate contents of a namespace by scanning its data structures for correctness. Slow. |
| whatsmyuri | S | {whatsmyuri:1} |
| writeBacksQueued | S A | Returns whether there are operations in the writeback queue at the time the command was called. This is an internal comand |
| writebacklisten | S A | internal |