Successfully reported this slideshow.
Your SlideShare is downloading. ×

MongoDB-Beginner tutorial explaining basic operation via mongo shell

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 14 Ad
Advertisement

More Related Content

Viewers also liked (20)

Advertisement

MongoDB-Beginner tutorial explaining basic operation via mongo shell

  1. 1. By Priti Solanki This presentation is to give you a quick way to start with Mongo shell
  2. 2. Tips
  3. 3. How to list all database
  4. 4. How to create empty database
  5. 5. How to view collections within mongo db > use ninja//Your db name switched to db ninja > show collections system.indexes ninja
  6. 6. How to find details of specific ninja db.ninja.find({'codename':'Sakura'}) { "_id" : ObjectId("534e5c3b17d860326a37faa0"), "codename" : "Sakura", "name" : [ { "firstname" : "Sakura", "lastname" : "Haruno" } ], "rank" : "Chunin", "team" : [ "Team kakashi", "Eight Man Squad" ], "classification" : [ "Medical-nin" ], "Jutsu" : [ "Chakra Enhanced strength", "Cherry Blossom Impact", "Yin seal" ] } Can’t read let’s make it pretty…. db.ninja.find({'codename':'Sakura'}).pretty() and checkout the output 
  7. 7. > db.ninja.find({'codename':'Naruto'}).pretty() { "Jutsu" : [ "Fire Dragon Missile", "Earth Landslide", "Black Rain", "Secret Tree", "Time reversal", "Water wall" ], "_id" : ObjectId("534e5fde17d860326a37faa1"), "clan" : "Uzumaki Clan", "classification" : [ "Jinchuriki", "Pseudo-Jinchuriki", "Sage" ], "codename" : "Naruto", "name" : [ { "firstname" : "Naruto", "lastname" : "Uzumaki" } ], "naturetype" : [ "wind release", "lava release", "yin-yang release" ], "rank" : "genin", "team" : [ "Team kakashi", "Sasuke retireval team" ] }
  8. 8. How to update specific document As we say, have you noticed Sakura collection show "Jutsu" not "naturetype". >db.ninja.update({'codename':'Naruto'},{$set:{'Jutsu':["Fire Dragon Missile","Earth Landslide","Black Rain","Secret Tree","Time reversal","Water wall"]}}
  9. 9. How to remove document? >db.ninja.remove({"codename":"Sakura"}) How to remove all documents in a collection? >db.ninja.remove({}) How to delete collection >db.ninja.drop()
  10. 10. So now, you can perform some of the basic operation on mongo db via mongo shell I hope these basic queries help you to give a good start I have added dummy documents in next slides. So that you can practice more by adding these documents To improve this tutorial for beginners please share your comments on pritiatwork@gmail.com
  11. 11. Dummy Document >db.ninja.save({codename:"Naruto",name:[{firstname:"Naruto",lastname:"Uz umaki"}],rank:"genin",team:["Team kakashi","Sasuke retireval team"],classification:["Jinchuriki","Pseudo-Jinchuriki","Sage"],clan:"Uzumaki Clan",naturetype:["wind release","lava release","yin-yang release"]}) >db.ninja.save({codename:"Sakura",name:[{firstname:"Sakura",lastname:"Har uno"}],rank:"Chunin",team:["Team kakashi","Eight Man Squad"],classification:["Medical-nin"],Jutsu:["Chakra Enhanced strength","Cherry Blossom Impact","Yin seal"]}) >db.ninja.save({codename:"Sasuke",name:[{firstname:"Sasuke",lastname:"Uc hiha"}],rank:"Genin",team:["Team kakashi","Sound Four","Taka"],classification:["Missing-nin"],Jutsu:["Amaterasu","Body Flame Technique","Chindori"]},naturetype:["Blaze release","Fire release","Lightning release"])

×