SlideShare a Scribd company logo
By Priti Solanki
This presentation is to give you a quick way to start with Mongo shell
MongoDB-Beginner tutorial explaining basic operation via 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
ninja
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 
> 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"
]
}
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"]}}
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()
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
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"])
MongoDB-Beginner tutorial explaining basic operation via mongo shell
MongoDB-Beginner tutorial explaining basic operation via mongo shell

More Related Content

What's hot (11)

PDF
MongoD Essentials
zahid-mian
Ā 
PPTX
Serial Killers - or Deserialization for fun and profit
blaufish
Ā 
PDF
MongoDB: Replication,Sharding,MapReduce
Takahiro Inoue
Ā 
KEY
Geospatial Indexing and Querying with MongoDB
Grant Goodale
Ā 
PDF
Ų§Ų³Ł„Ų§ŪŒŲÆ Ų³ŁˆŁ… جلسه هفتم کلاس Ł¾Ų§ŪŒŲŖŁˆŁ† برای Ł‡Ś©Ų±Ł‡Ų§ŪŒ Ł‚Ų§Ł†ŁˆŁ†ŪŒ
Mohammad Reza Kamalifard
Ā 
PPTX
jSession #3 - Krzysztof Czajkowski - Lombok in Java
jSession
Ā 
PPTX
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rick Copeland
Ā 
PPTX
MongoDB-SESSION03
Jainul Musani
Ā 
DOC
Implementation Specifications
Unmon Mukherjee
Ā 
PDF
Micro(Lightweight) Django
Grigory Petrov
Ā 
PDF
To infinity and beyond
clintongormley
Ā 
MongoD Essentials
zahid-mian
Ā 
Serial Killers - or Deserialization for fun and profit
blaufish
Ā 
MongoDB: Replication,Sharding,MapReduce
Takahiro Inoue
Ā 
Geospatial Indexing and Querying with MongoDB
Grant Goodale
Ā 
Ų§Ų³Ł„Ų§ŪŒŲÆ Ų³ŁˆŁ… جلسه هفتم کلاس Ł¾Ų§ŪŒŲŖŁˆŁ† برای Ł‡Ś©Ų±Ł‡Ų§ŪŒ Ł‚Ų§Ł†ŁˆŁ†ŪŒ
Mohammad Reza Kamalifard
Ā 
jSession #3 - Krzysztof Czajkowski - Lombok in Java
jSession
Ā 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rick Copeland
Ā 
MongoDB-SESSION03
Jainul Musani
Ā 
Implementation Specifications
Unmon Mukherjee
Ā 
Micro(Lightweight) Django
Grigory Petrov
Ā 
To infinity and beyond
clintongormley
Ā 

Viewers also liked (20)

PPTX
Mongo DB
Tata Consultancy Services
Ā 
PPTX
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
SpringPeople
Ā 
PDF
Intro To MongoDB
Alex Sharp
Ā 
PPT
Introduction to MongoDB
Ravi Teja
Ā 
PPTX
Intro To Mongo Db
chriskite
Ā 
PDF
Business considerations for node.js applications
Aspenware
Ā 
KEY
Getting Started with MongoDB and Node.js
Grant Goodale
Ā 
PPT
Mongo db tutorials
Anuj Jain
Ā 
KEY
Administration (Eliot Horowitz)
MongoSF
Ā 
PPTX
MediaGlu and Mongo DB
Sundar Nathikudi
Ā 
PPTX
Shankar's mongo db presentation
Shankar Kamble
Ā 
PDF
Mongo db basics
Harischandra M K
Ā 
PPT
Mongo db basics
Dhaval Mistry
Ā 
PPTX
Connecting NodeJS & MongoDB
Enoch Joshua
Ā 
PDF
NOSQL Overview
Tobias Lindaaker
Ā 
PPTX
NoSQL databases - An introduction
Pooyan Mehrparvar
Ā 
PDF
Mongo db
Noman Ellahi
Ā 
ZIP
NoSQL databases
Harri Kauhanen
Ā 
PPTX
MongoDB for Beginners
Enoch Joshua
Ā 
PPTX
Mongo DB
Karan Kukreja
Ā 
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
SpringPeople
Ā 
Intro To MongoDB
Alex Sharp
Ā 
Introduction to MongoDB
Ravi Teja
Ā 
Intro To Mongo Db
chriskite
Ā 
Business considerations for node.js applications
Aspenware
Ā 
Getting Started with MongoDB and Node.js
Grant Goodale
Ā 
Mongo db tutorials
Anuj Jain
Ā 
Administration (Eliot Horowitz)
MongoSF
Ā 
MediaGlu and Mongo DB
Sundar Nathikudi
Ā 
Shankar's mongo db presentation
Shankar Kamble
Ā 
Mongo db basics
Harischandra M K
Ā 
Mongo db basics
Dhaval Mistry
Ā 
Connecting NodeJS & MongoDB
Enoch Joshua
Ā 
NOSQL Overview
Tobias Lindaaker
Ā 
NoSQL databases - An introduction
Pooyan Mehrparvar
Ā 
Mongo db
Noman Ellahi
Ā 
NoSQL databases
Harri Kauhanen
Ā 
MongoDB for Beginners
Enoch Joshua
Ā 
Mongo DB
Karan Kukreja
Ā 
Ad

Similar to MongoDB-Beginner tutorial explaining basic operation via mongo shell (20)

PDF
Using MongoDB and Python
Mike Bright
Ā 
PDF
2016 feb-23 pyugre-py_mongo
Michael Bright
Ā 
DOCX
unit 4,Indexes in database.docx
RaviRajput416403
Ā 
PPTX
MongoDB installation,CRUD operation & JavaScript shell
ShahDhruv21
Ā 
KEY
MongoDB Command Line Tools
Rainforest QA
Ā 
PPTX
introtomongodb
saikiran
Ā 
ODP
Mongo db rev001.
Rich Helton
Ā 
PPTX
Getting Started with MongoDB
Ahasanul Kalam Akib
Ā 
PPTX
MongoDB introduction features -presentation - 2.pptx
sampathkumar546444
Ā 
PPTX
MongoDb and NoSQL
TO THE NEW | Technology
Ā 
PPTX
Introduction to MongoDB
S.Shayan Daneshvar
Ā 
PDF
Mongo db halloween party
Andrea Balducci
Ā 
PPTX
Introduction to MongoDB at IGDTUW
Ankur Raina
Ā 
PPTX
MongoDB
Bembeng Arifin
Ā 
PDF
Quick overview on mongo db
Eman Mohamed
Ā 
PPTX
Introduction to MongoDB
MongoDB
Ā 
KEY
London MongoDB User Group April 2011
Rainforest QA
Ā 
PDF
MongoDB for Coder Training (Coding Serbia 2013)
Uwe Printz
Ā 
PDF
Mongodb Introduction
Raghvendra Parashar
Ā 
PPTX
MongoDB is a document database. It stores data in a type of JSON format calle...
amintafernandos
Ā 
Using MongoDB and Python
Mike Bright
Ā 
2016 feb-23 pyugre-py_mongo
Michael Bright
Ā 
unit 4,Indexes in database.docx
RaviRajput416403
Ā 
MongoDB installation,CRUD operation & JavaScript shell
ShahDhruv21
Ā 
MongoDB Command Line Tools
Rainforest QA
Ā 
introtomongodb
saikiran
Ā 
Mongo db rev001.
Rich Helton
Ā 
Getting Started with MongoDB
Ahasanul Kalam Akib
Ā 
MongoDB introduction features -presentation - 2.pptx
sampathkumar546444
Ā 
MongoDb and NoSQL
TO THE NEW | Technology
Ā 
Introduction to MongoDB
S.Shayan Daneshvar
Ā 
Mongo db halloween party
Andrea Balducci
Ā 
Introduction to MongoDB at IGDTUW
Ankur Raina
Ā 
MongoDB
Bembeng Arifin
Ā 
Quick overview on mongo db
Eman Mohamed
Ā 
Introduction to MongoDB
MongoDB
Ā 
London MongoDB User Group April 2011
Rainforest QA
Ā 
MongoDB for Coder Training (Coding Serbia 2013)
Uwe Printz
Ā 
Mongodb Introduction
Raghvendra Parashar
Ā 
MongoDB is a document database. It stores data in a type of JSON format calle...
amintafernandos
Ā 
Ad

Recently uploaded (20)

PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
Ā 
PDF
šŸš€ Let’s Build Our First Slack Workflow! šŸ”§.pdf
SanjeetMishra29
Ā 
PPTX
Securing Model Context Protocol with Keycloak: AuthN/AuthZ for MCP Servers
Hitachi, Ltd. OSS Solution Center.
Ā 
PDF
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pdf
ghjghvhjgc
Ā 
PDF
NASA A Researcher’s Guide to International Space Station : Fundamental Physics
Dr. PANKAJ DHUSSA
Ā 
PDF
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
Ā 
PDF
Software Development Company Keene Systems, Inc (1).pdf
Custom Software Development Company | Keene Systems, Inc.
Ā 
PDF
ā€œSquinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
Ā 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
Ā 
PPTX
Manual Testing for Accessibility Enhancement
Julia Undeutsch
Ā 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
Ā 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
Ā 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
Ā 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
Ā 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
Ā 
PDF
Linux schedulers for fun and profit with SchedKit
Alessio Biancalana
Ā 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
Ā 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
Ā 
PDF
NASA A Researcher’s Guide to International Space Station : Earth Observations
Dr. PANKAJ DHUSSA
Ā 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
Ā 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
Ā 
šŸš€ Let’s Build Our First Slack Workflow! šŸ”§.pdf
SanjeetMishra29
Ā 
Securing Model Context Protocol with Keycloak: AuthN/AuthZ for MCP Servers
Hitachi, Ltd. OSS Solution Center.
Ā 
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pdf
ghjghvhjgc
Ā 
NASA A Researcher’s Guide to International Space Station : Fundamental Physics
Dr. PANKAJ DHUSSA
Ā 
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
Ā 
Software Development Company Keene Systems, Inc (1).pdf
Custom Software Development Company | Keene Systems, Inc.
Ā 
ā€œSquinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
Ā 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
Ā 
Manual Testing for Accessibility Enhancement
Julia Undeutsch
Ā 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
Ā 
The Project Compass - GDG on Campus MSIT
dscmsitkol
Ā 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
Ā 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
Ā 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
Ā 
Linux schedulers for fun and profit with SchedKit
Alessio Biancalana
Ā 
Wondershare Filmora Crack Free Download 2025
josanj305
Ā 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
Ā 
NASA A Researcher’s Guide to International Space Station : Earth Observations
Dr. PANKAJ DHUSSA
Ā 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
Ā 

MongoDB-Beginner tutorial explaining basic operation via mongo shell

  • 1. By Priti Solanki This presentation is to give you a quick way to start with Mongo shell
  • 4. How to list all database
  • 5. How to create empty database
  • 6. How to view collections within mongo db > use ninja//Your db name switched to db ninja > show collections system.indexes ninja
  • 7. 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 
  • 8. > 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" ] }
  • 9. 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"]}}
  • 10. 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()
  • 11. 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 [email protected]
  • 12. 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"])