Basic shell commands.
Group Operators $last | return the last value in a group $first | return the first value in a group $min | return the lowest value in a group $avg | return an average of all values in a group $addToSet | return a unique array of values for group $max | return the highest value in a group $push | return an array of values for a grouped field $and | returns true when all values in array are true $or | returns true when any value in its array are true $not | returns boolean value that is opposite of input $eq | return true if two values are equal Comparison Operators $cmp | return the result of a compare as an integer
Not sorted commands (in pdf link below grouped by terms)
help | get help for the context you are in db | show the selected database show dbs | show databases on server show collections | show collections in the current db use foo | select and use the database fooCollection commands (db.collection.) mapReduce() | performs mapreduce data aggregate copyTo() | copy a collection to a new collection name renameCollection() | rename a collection drop() | remove the collection from the database help() | show a list of help commands for a collection command line options:host hostname | hostname to connect toport 27017 | connect to port 27017 (default)u foo | username foop bar | password barauthenticationDatabase arg | database to authenticate to mongotop | profile the resources mongo is consuming mongostat | profile the amount of time spent in collections mongoimport | import data from a file to mongodb mongodump | dump contents of a database to files mongorestore | restore contents of a dump to a database exit | exit the shell show users | show the users in the current db getLastError() | get status of last error stats() | get stats on the current db selected help() | show a list of help commands for a dbIndexing ensureIndex() | creates an index if it does not currently exist reIndex() | rebuilds all existing indexes on a collection getIndexes() | gets details on the indexes on a collection dropIndex() | removes a specified index on a collection compact | defragments a collection and rebuilds the indexesCursors (db.collection.find.) limit() | constrain the size of a cursors result set skip() | skip through some documents and then return results sort() | return results ordered according to a sort specification next() | return the next document in a cursor count() | return a count of the documents in a cursor toArray() | return an array of all documents for the cursor explain() | get the query execution plan for a cursor hint() | force db to use a specific index for a query count() | get number of documents in the collection stats() | get stats about the collection hasNext() | true if cursor has documents and can be iterated it | iterate on a cursorReplication (rs.) add() | adds a member to a replica set initiate() | initializes a new replica set addArb() | adds an arbiter to a replica set conf() | returns the replica set config document freeze() | prevents a member from becoming primary help() | get basic help for replica set functionsSharding (sh.) addShard() | add a shard to the cluster addShardTag() | associate a shard with a tagAuthentication db.addUser() | add a user to system.users or admin collection db.auth() | authenticates a user to a databaseProjection Operators ( $ ) $slice | limit number of elements projected from array $elemMatch | project only the first element match $ | project the first element in an array that matchesAggregation Operators ( $ )