By Priti Solanki
This presentation is to give you a quick way to start with Mongo shell
Tips
How to list all database
How to create empty database
How to view collections within mongo db
> use ninja//Your db name
switched to db ninja
> show collections
system.indexes
n...
How to find details of specific ninja
db.ninja.find({'codename':'Sakura'})
{ "_id" : ObjectId("534e5c3b17d860326a37faa0")...
> db.ninja.find({'codename':'Naruto'}).pretty()
{
"Jutsu" : [
"Fire Dragon Missile",
"Earth Landslide",
"Black Rain",
"Sec...
How to update specific document
As we say, have you noticed Sakura collection show "Jutsu" not
"naturetype".
>db.ninja.upd...
How to remove document?
>db.ninja.remove({"codename":"Sakura"})
How to remove all documents in a collection?
>db.ninja.rem...
So now, you can perform some of the basic operation on mongo db
via mongo shell
I hope these basic queries help you to giv...
Dummy Document
>db.ninja.save({codename:"Naruto",name:[{firstname:"Naruto",lastname:"Uz
umaki"}],rank:"genin",team:["Team ...
MongoDB-Beginner tutorial explaining basic operation via mongo shell
MongoDB-Beginner tutorial explaining basic operation via mongo shell
MongoDB-Beginner tutorial explaining basic operation via mongo shell
Upcoming SlideShare
Loading in …5
×

MongoDB-Beginner tutorial explaining basic operation via mongo shell

1,979 views

Published on

This is a beginner tutorial which give quick start with mongoDB.

1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total views
1,979
On SlideShare
0
From Embeds
0
Number of Embeds
731
Actions
Shares
0
Downloads
1
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

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"])

×