Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Create DB
- =========
- ~~~~
- use dataase_name
- ~~~~
- You will have to insert a value inorder for the db to get showcased in show dbs command.
- Show Commands
- =============
- ~~~~
- show dbs # To see all the database names
- show collections # To see all the collection names
- db.getCollectionNames()
- ~~~~
- Creating & Inserting key-value in a Collections
- ===============================================
- ~~~~
- db.createCollection("NameOfTheCollection")
- # Automatically adds an id to the document
- db.createCollection("NameOfTheCollection", {autoIndexId : true})
- db.NameOftheCollection.insert({"key":"value"})
- ~~~~
- To see the content of the collections
- =====================================
- ~~~~
- db.collectionName.find()
- db.collectionName.find().pretty()
- db.collectionName.find({key : {$eq : value}}).pretty() # Search for a particular key
- db.AutoIDActor.count() # Count the number of collections
- ~~~~
- Will make this list more comprehensive on the fly
Add Comment
Please, Sign In to add comment