Index
Examples


Open command prompt
> mongo
Shell Opens


> show dbs
> show collections
> use rec_db
> db.recs.find().pretty()
> use ghana_pro_db
> show collections
> db.refs.find()


Where is the mongo shell history file:

#Windows
	In command prompt:
		> echo %HOMEPATH%
		\Users\Foo
Thus shell history file path is:
	C:\Users\Foo\.dbshell
Notes:
	echo %ProgramData%
	echo %HOMEDRIVE%


Example Shell Usage


Open command prompt
> mongo
Shell Opens

> show dbs
admin          0.000GB
bookstore_db   0.000GB
config         0.000GB
...
> use bookstore_db
switched to db bookstore_db
> show collections
books
recs
> db.recs.find()
{ "_id" : ObjectId("6171cebd14dca31aec52a121"), "w" : 10, "h" : 2, "__v" : 0 }
{ "_id" : ObjectId("6171cebd14dca31aec52a122"), "w" : 8, "h" : 7, "__v" : 0 }
{ "_id" : ObjectId("6171cf5a9aa4691ee881cff1"), "w" : 10, "h" : 2, "__v" : 0 }
{ "_id" : ObjectId("6171cf5a9aa4691ee881cff2"), "w" : 8, "h" : 7, "__v" : 0 }
> db.recs.find( {w: {$gt: 9} })
{ "_id" : ObjectId("6171cebd14dca31aec52a121"), "w" : 10, "h" : 2, "__v" : 0 }
{ "_id" : ObjectId("6171cf5a9aa4691ee881cff1"), "w" : 10, "h" : 2, "__v" : 0 }
> db.recs.find( {w: {$lt: 9} })
{ "_id" : ObjectId("6171cebd14dca31aec52a122"), "w" : 8, "h" : 7, "__v" : 0 }
{ "_id" : ObjectId("6171cf5a9aa4691ee881cff2"), "w" : 8, "h" : 7, "__v" : 0 }
>


Drop Database


> help
> db.help()
#db.dropDatabase
> cls
> show dbs
> use temp_db
> db.dropDatabase()


References