View Current Database
MongoDB shell version: 1.8 . 1
Connecting to: Test
> DB
Test
View the list of all databases
> Show DBS
Chatroom 0.03125 GB
Admin (empty)
Local (empty)
Switch Database
> Use chatroom
Switched to DB chatroom
> DB
Chatroom
Delete Database
> DB
Chatroom
> Show DBS
Chatroom 0.03125 GB
Admin (empty)
Local (empty)
> DB. dropdatabase ()
{ " Dropped " : " Chatroom " , " OK " : 1 }
> Show DBS
Admin (empty)
Local (empty)
MongoDB help topic help
> Help DB. Help () Help on DB Methods
DB. mycoll. Help () Help on collection methods
Rs. Help () Help on replica set methods
Help connect ing to a DB help
Help admin administrative help
Help MISC things to know
Help Mr mapreduce help
Show DBS show database names
Show collections show collections In Current Database
Show users show users In Current Database
Show profile show most recent system. Profile entries with time > = 1 ms
Use < Db_name > Set Current Database
DB. Foo. Find () List objects In Collection foo
DB. Foo. Find ({: 1 }) List objects In Foo where = 1
It result of the last line evaluated; use to furtheriterate
Dbquery. shellbatchsize = X set default number of items to display on Shell
Exit quit the Mongo Shell
> DB. Help ()
DB methods:
DB. adduser (username, password [, readonly = False])
DB. Auth (username, password)
DB. clonedatabase (fromhost)
DB. commandhelp (name) returns the help For The command
DB. copydatabase (fromdb, todb, fromhost)
DB. createcollection (name, {size:..., capped:..., Max :...})
DB. currentop () displays the current operation In The DB
DB. dropdatabase ()
DB. eval (func, argS) run code Server - Side
DB. getcollection (cname) Same As DB [ ' Cname ' ] Or DB. cname
DB. getcollectionnames ()
DB. getlasterror () - Just returns the err MSG string
DB. getlasterrorobj () - Return Full status object
DB. getmongo () Get the server connection object
DB. getmongo (). setslaveok () allow this connection to read From The nonmaster member of a replica pair
DB. getname ()
DB. getpreverror ()
DB. getprofilinglevel () - Deprecated
DB. getprofilingstatus () - Returns If Profiling Is On And Slow threshold
DB. getreplicationinfo ()
DB. getsiblingdb (name) Get the dB at the same server as this one
DB. ismaster () Check replica primary status
DB. Killop (opid) kills the current operation In The DB
DB. listcommands () lists all the DB commands
DB. printcollectionstats ()
DB. printreplicationinfo ()
DB. printslavereplicationinfo ()
DB. printshardingstatus ()
DB. removeuser (username)
DB. repairdatabase ()
DB. reseterror ()
DB. runcommand (cmdobj) run a database command. If Cmdobj Is A string, turns it into {cmdobj: 1 }
DB. serverstatus ()
DB. setprofilinglevel (level, < Slowms > ) 0 = Off 1 = Slow 2 = All
DB. shutdownserver ()
DB. Stats ()
DB. Version () Current version of the server
DB. getmongo (). setslaveok () Allow queries on a replication slave server