All notes
MongoDB
## Mongo client References: * [mongoDB Doc](http://docs.mongodb.org/manual/reference/mongo-shell/) Intro: * Command history is stored in ~/.dbshell file. ### Help ```sql help admin // administrative help help connect // connecting to a db help help keys // key shortcuts help misc // misc things to know help mr // mapreduce ``` ### Query [MongoDB Doc](http://docs.mongodb.org/manual/tutorial/query-documents/) ```sql show databases use __DatabaseName__ show tables // Show collection's content. db.__CollectionName__.find() // list objects in foo where a == 1 db.foo.find( { a : 1 } ) ``` ### Insert [MongoDB Doc](http://docs.mongodb.org/manual/reference/method/db.collection.insert/#db.collection.insert) Insert a new document into the collection. ```sql db.products.insert( { item: "card", qty: 15 } ) // During the insert, mongod will create the _id field and assign it a unique ObjectId value: // { "_id" : ObjectId("5063114bd386d8fadbd6b004"), "item" : "card", "qty" : 15 } ``` ### Remove, delete ```sql db.accounts.remove({"username":"mrWang"}) // CAUTION: this command will remove all items! db.accounts.remove({}) ```