Guest User

Untitled

a guest
Feb 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. Create DB
  2. =========
  3.  
  4. ~~~~
  5. use dataase_name
  6. ~~~~
  7.  
  8. You will have to insert a value inorder for the db to get showcased in show dbs command.
  9.  
  10. Show Commands
  11. =============
  12.  
  13. ~~~~
  14. show dbs # To see all the database names
  15.  
  16. show collections # To see all the collection names
  17. db.getCollectionNames()
  18. ~~~~
  19.  
  20. Creating & Inserting key-value in a Collections
  21. ===============================================
  22.  
  23. ~~~~
  24. db.createCollection("NameOfTheCollection")
  25.  
  26. # Automatically adds an id to the document
  27. db.createCollection("NameOfTheCollection", {autoIndexId : true})
  28.  
  29. db.NameOftheCollection.insert({"key":"value"})
  30. ~~~~
  31.  
  32. To see the content of the collections
  33. =====================================
  34.  
  35. ~~~~
  36. db.collectionName.find()
  37. db.collectionName.find().pretty()
  38.  
  39. db.collectionName.find({key : {$eq : value}}).pretty() # Search for a particular key
  40.  
  41. db.AutoIDActor.count() # Count the number of collections
  42. ~~~~
  43.  
  44. Will make this list more comprehensive on the fly
Add Comment
Please, Sign In to add comment