- Reference >
mongo
Shell JavaScript Quick Reference
mongo
Shell JavaScript Quick Reference¶
Methods
On this page
Data Manipulation¶
Query and Update Methods¶
Cursor Methods¶
Call cursor methods on cursors to modify how MongoDB returns objects to the cursor.
Data Aggregation Methods¶
Administrative Functions¶
Database Methods¶
db.addUser()
db.auth()
db.cloneDatabase()
db.commandHelp()
db.copyDatabase()
db.createCollection()
db.currentOp()
db.dropDatabase()
db.eval()
db.fsyncLock()
db.fsyncUnlock()
db.getCollection()
db.getCollectionNames()
db.getLastError()
db.getLastErrorObj()
db.getMongo()
db.getName()
db.getProfilingLevel()
db.getProfilingStatus()
db.getSiblingDB()
db.killOp()
db.listCommands()
db.loadServerScripts()
db.logout()
db.printCollectionStats()
db.removeUser()
db.repairDatabase()
db.runCommand()
db.serverBuildInfo()
db.serverStatus()
db.setProfilingLevel()
db.shutdownServer()
db.stats()
db.version()
Collection Methods¶
These methods operate on collection objects. Also consider the “Query and Update Methods” and “Cursor Methods” documentation for additional methods that you may use with collection objects.
Note
Call these methods on a collection object in the shell
(i.e. db.collection.[method]()
, where collection
is the
name of the collection) to produce the documented behavior.
db.collection.dataSize()
db.collection.distinct()
db.collection.drop()
db.collection.dropIndex()
db.collection.dropIndexes()
db.collection.ensureIndex()
db.collection.getIndexes()
db.collection.getShardDistribution()
db.collection.getShardVersion()
db.collection.reIndex()
db.collection.remove()
db.collection.renameCollection()
db.collection.stats()
db.collection.storageSize()
db.collection.totalIndexSize()
db.collection.totalSize()
db.collection.validate()
Mongo.getDB()
Sharding Methods¶
See also
The “Sharded Cluster Overview” page for more information on the sharding technology and using MongoDB’s sharded clusters.
db.printShardingStatus()
sh.addShard()
sh.addShardTag()
sh.addTagRange()
sh._adminCommand()
sh._checkMongos()
sh._checkFullName()
sh.disableBalancing()
sh.enableBalancing()
sh.enableSharding()
sh.getBalancerHost()
sh.help()
sh._lastMigration()
sh.isBalancerRunning()
sh.moveChunk()
sh.removeShardTag()
sh.setBalancerState()
sh.shardCollection()
sh.splitAt()
sh.splitFind()
sh.startBalancer()
sh.status()
sh.stopBalancer()
sh.waitForBalancerOff()
sh.waitForBalancer()
sh.waitForDLock()
sh.waitForPingChange()
Replica Set Methods¶
See also
Replica Set Fundamental Concepts for more information regarding replication.
Native Shell Methods¶
These methods provide a number of low level and internal functions
that may be useful in the context of some advanced operations in the
shell. The JavaScript standard library is accessible in the
mongo
shell.
Date()
cat()
cd()
fuzzFile()
getHostName()
getMemInfo()
hostname()
listFiles()
load()
ls()
md5sumFile()
mkdir()
pwd()
quit()
removeFile()
Non-User Functions and Methods¶
Deprecated Methods¶
Native Methods¶
_isWindows()
rand()
srand()
Internal Methods¶
These methods are accessible in the shell but exist to support other functionality in the environment. Do not call these methods directly.
_startMongoProgram()
clearRawMongoProgramOutput()
copyDbpath()
rawMongoProgramOutput()
resetDbpath()
run()
runMongoProgram()
runProgram()
stopMongoProgram()
stopMongoProgramByPid()
stopMongod()
waitMongoProgramOnPort()
waitProgram()