Command |
Requires Auth |
Admin Only |
Slave Okay |
Description |
| |
No |
No |
Yes |
Info on any assertions thrown:
{dbasserted : boolean,
asserted : boolean,
assert : string,
assertw : string,
assertmsg : string,
assertuser : string,
ok : 1}
|
| |
No |
Yes |
Yes |
Returns:
{version : dbVersion, gitVersion : gitCommitId, sysInfo : osInfo, ok : 1}
|
| |
Yes |
No |
No |
Copy the current database from another host to here. DocPage |
{collstats : collection_name}
|
No |
No |
No |
Gets statistics about a collection. |
{convertToCapped : collection_name, size : size_in_bytes}
|
No |
No |
No |
Convert a collection to capped. This command is rarely used and is not currently supported with sharding. |
{ copydb : 1, fromdb : ...,
todb : ..., fromhost : ...,
username: ..., nonce: ..., key: ... }
|
Yes |
Yes |
No |
Copy a database, potentially from another host. The username, nonce, and key arguments are only required if the source database needs authentication. DocPage |
{ copydbgetnonce : 1, fromhost : ... }
|
Yes |
Yes |
No |
Get a nonce for a subsequent call to copydb using a secure source database. DocPage |
{ count : collection_name, query : query_spec, fields : [field1, field2] }
|
No |
No |
No |
Returns a count for the specified query. |
{ create : name, capped : boolean, size : N[, max : N] }
|
No |
No |
No |
Creates a collection |
| |
No |
No |
Yes |
Display stats on the database. Invoke via db.stats() in the mongo shell. |
{deleteIndexes : coll_name,
index : index_name}
|
No |
No |
? |
Deletes one or all (if index_name is "*") indexes. |
{distinct : collection_name,
key : key_name
[, query : a_query ]
}
|
No |
No |
Yes |
Finds all distinct values for a given key. |
| |
No |
No |
No |
Drops a collection. |
| |
No |
No |
No |
Drops this database. |
{filemd5 : object_id, root : file_root}
|
No |
No |
Yes |
Finds the MD5 hash of a GridFS file. file_root is the prefix of the files and chunks collections. For example, with the default fs.files and fs.chunks collections, it would be "fs". |
{findAndModify : collection_name, query: query_filter, update: update_modifier_object, sort: sort_order, remove: boolean, new: boolean}
|
No |
No |
No |
Commanding for atomically updating and returning a document. See [findandmofify] for specifics. |
| |
No |
No |
Yes |
Forces a database error.
{assertion : "forced error", errmsg : "db assertion failure", ok : 0}
|
{ fsync : 1[, async : true] }
|
No |
Yes |
Yes |
|
| |
No |
No |
Yes |
Returns if there was an error on the previous database operation. [DocPage]
{err : error, n : numberOfErrors, ok : 1}
|
| |
No |
No |
Yes |
{optime : Timestamp, ok : 1}
|
| |
No |
No |
Yes |
Returns when the last database error occured.
{err : error, n : numberOfErrors, nPrev : numberOfOperationsAgo, ok : 1}
|
{nIndexesWas : N, ok : 1}
|
No |
No |
No |
{nIndexesWas : N,
msg : "all indexes deleted for collection",
ns : namespace,
"ok" : 1}
|
| |
No |
No |
Yes |
Used with replica pairs . |
| |
No |
Yes |
Yes |
Returns a list of database names and sizes. |
| |
No |
Yes |
Yes |
Generate a diagnostic log file for replay of operations. |
| |
No |
No |
Yes |
If passed -1, gets the profiling level, if passed 0-2, sets the profiling level.
{was : previousLevel, ok : 1}
|
| |
No |
Yes |
Yes |
|
{renameCollection : <collectionToRename>, to: <new collection name>, dropTarget: <boolean>}
|
No |
Yes |
No |
Note that the full collection names must be provided (e.g., <dbname>.<collectionname>) |
{repairDatabase : 1,
preserveClonedFilesOnFailure : boolean,
backupOriginalFiles : boolean}
|
No |
No |
Yes |
Repairs/compacts this database. |
| |
No |
No |
Yes |
Clears previous database errors. Returns: |
{serverStatus : 1[, , repl : N ]}
|
No |
No |
Yes |
uptime/lock info/memory info - since 1.1.2
N:
- 0 - none
- 1 - local (doesn't have to connect to other server)
- 2 - remote (has to check with the master)
|
| |
Yes |
Yes |
Yes |
Shuts down the database server. Returns nothing. DocPage |
| |
Yes |
Yes |
Yes |
Rotate logs if using --logpath DocPage |
IF YOU HAVE A QUESTION, POST IT TO THE USER GROUP.
These pages are fine for comments, but for questions, your best bet will always be the MongoDB User Group. blog comments powered by Disqus