SlideShare uma empresa Scribd logo
1 de 25
MongoDB
MongoDB is a document-oriented database, not a relational one.
A document-oriented database replaces the concept of a “row” with a more flexible
model, the “document.”
MongoDB is intended to be a general-purpose database so aside from creating, reading,
updating, and deleting data
Indexing
Aggregation
Special collection types
MongoDB is made up of databases which contain collections. A collection is made up of
documents.
Each document is made up of fields. Collections can be indexed, which improves lookup and
sorting performance.
Finally, when we get data from MongoDB we do so through a cursor whose actual execution is
delayed until necessary.
In JavaScript, for example, documents are represented as objects:
{
"greeting“ : "Hello, world!“
}
This simple document contains a single key, "greeting“ , with a value of "Hello,
world!“ . Most documents will be more complex than this simple one and often will
contain multiple key/value pairs:
{ "greeting“ :"Hello, world!","foo":3 }
The keys in a document are strings. Any UTF-8 character is allowed in a key, with a few
notable exceptions:
Keys must not contain the character 0 (the null character). This character is used
to signify the end of a key
The . and $ characters have some special properties and should be used only in certain
circumstances, as described in later chapters. In general, they should be considered reserved,
and drivers will complain if they are used inappropriately.
MongoDB is type-sensitive and case-sensitive
Collections:
A collection is a group of documents.
Dynamic Schemas:
Collections have dynamic schemas . This means that the documents within a single col‐
lection can have any number of different “shapes.”
{"greeting“ : "Hello, world!"}
{ "foo":5}
Naming:
A collection is identified by its name. Collection names can be any UTF-8 string, with
a few restrictions:
The empty string ("") is not a valid collection name
Collection names may not contain the character 0 (the null character) because this delineates
the end of a collection name.
Getting and Starting MongoDB
MongoDB is almost always run as a network server that clients can connect to and
perform operations on
$ mongod
mongod --help
for help and startup options.
When run with no arguments, mongod will use the default data directory, /data/db/
(or datadb on the current volume on Windows).
If the data directory does not already exist or is not writable, the server will fail to start. It is
important to create the data directory (e.g., mkdir -p /data/db/ ) and to make sure your user
has permission to write to the directory before starting MongoDB
Running the Shell
To start the shell, run the mongo executable:
$Mongo
MongoDB shell
version : 2.4 . 0
connecting to : test >
The shell is a full-featured JavaScript interpreter, capable of running arbitrary JavaScript
programs. To illustrate this, let’s perform some basic math:
>x
=200
200
>x/5;
40
A MongoDB Client
To see the database db is currently assigned to, type in db and hit Enter:
>db
Test
Basic Operations with the Shel
CRUD:
create, read, update, and delete to manipulate and view data in the shell.
Data Types
Basic Data Types
Documents in MongoDB can be thought of as “JSON-like” in that they are conceptually
similar to objects in JavaScript.
JSON is a simple representation of data: the specification can be described in about one
paragraph (their website proves it) and lists only six data types.
The most common types are
Null
Dates
Arrays
Embedded documents
Running Scripts with the Shel
Creating, Updating, and
Deleting Documents
Adding new documents to a collection
• Removing documents from a collection
• Updating existing documents
• Choosing the correct level of safety versus speed for all of these operations
Inserting and Saving Documents
Inserts are the basic method for adding data to MongoDB.
Batch Insert
Batch inserts allow you to pass an array of documents to the database.
Insert Validation
MongoDB does minimal checks on data being inserted:
Removing Documents
Now that there’s data in our database, let’s delete it:
Remove Speed
Removing documents is usually a fairly quick operation.
Updating Documents
Setting a Write Concern
Querying
Find method is used to perform queries in MongoDB.
Specifying Which Keys to Return
Sometimes you do not need all of the key/value pairs in a document returned.
Cursors
The database returns results from find using a cursor.

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Mongo DB 102
Mongo DB 102Mongo DB 102
Mongo DB 102
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo db
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
 
Connecting NodeJS & MongoDB
Connecting NodeJS & MongoDBConnecting NodeJS & MongoDB
Connecting NodeJS & MongoDB
 
MongoDB 101
MongoDB 101MongoDB 101
MongoDB 101
 
Mongo db
Mongo dbMongo db
Mongo db
 
Mongo DB Presentation
Mongo DB PresentationMongo DB Presentation
Mongo DB Presentation
 
MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentation
 
MongoDB
MongoDBMongoDB
MongoDB
 
Mongo db workshop # 01
Mongo db workshop # 01Mongo db workshop # 01
Mongo db workshop # 01
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
MongoDB: An Introduction - june-2011
MongoDB:  An Introduction - june-2011MongoDB:  An Introduction - june-2011
MongoDB: An Introduction - june-2011
 
The Basics of MongoDB
The Basics of MongoDBThe Basics of MongoDB
The Basics of MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Introduction to mongodb
Introduction to mongodbIntroduction to mongodb
Introduction to mongodb
 
An introduction to MongoDB
An introduction to MongoDBAn introduction to MongoDB
An introduction to MongoDB
 
Mongo db
Mongo dbMongo db
Mongo db
 
Mongo db dhruba
Mongo db dhrubaMongo db dhruba
Mongo db dhruba
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 

Destaque

Rehabilitacion Psicosicial Jornada cd lleida 2011
Rehabilitacion Psicosicial Jornada cd lleida 2011Rehabilitacion Psicosicial Jornada cd lleida 2011
Rehabilitacion Psicosicial Jornada cd lleida 2011
jrbellidomainar
 
CURRICULUM VITAE GR
CURRICULUM VITAE GRCURRICULUM VITAE GR
CURRICULUM VITAE GR
Girdhari Ram
 
Appreciating differences certificate
Appreciating differences certificateAppreciating differences certificate
Appreciating differences certificate
Rehan Mohamed
 
на барикадах кенгіра
на барикадах кенгірана барикадах кенгіра
на барикадах кенгіра
kayasavchuk
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Tour
oscon2007
 

Destaque (20)

Innovative
InnovativeInnovative
Innovative
 
Steve Carpenter Art | Four Seasons Mural | Press Release 2014
Steve Carpenter Art | Four Seasons Mural | Press Release 2014Steve Carpenter Art | Four Seasons Mural | Press Release 2014
Steve Carpenter Art | Four Seasons Mural | Press Release 2014
 
Open educational resources - Pros and Cons
Open educational resources - Pros and ConsOpen educational resources - Pros and Cons
Open educational resources - Pros and Cons
 
How to leave smoking
How to leave smokingHow to leave smoking
How to leave smoking
 
Siddhant Resume 1
Siddhant Resume 1Siddhant Resume 1
Siddhant Resume 1
 
Rehabilitacion Psicosicial Jornada cd lleida 2011
Rehabilitacion Psicosicial Jornada cd lleida 2011Rehabilitacion Psicosicial Jornada cd lleida 2011
Rehabilitacion Psicosicial Jornada cd lleida 2011
 
דוקטור מוטי משיח על התמכרות לאלכוהול
דוקטור מוטי משיח על התמכרות לאלכוהולדוקטור מוטי משיח על התמכרות לאלכוהול
דוקטור מוטי משיח על התמכרות לאלכוהול
 
M F -CV 2015
M F -CV 2015M F -CV 2015
M F -CV 2015
 
ASU Degree
ASU DegreeASU Degree
ASU Degree
 
CURRICULUM VITAE GR
CURRICULUM VITAE GRCURRICULUM VITAE GR
CURRICULUM VITAE GR
 
Fragkopoulou_Katerina_Master thesis
Fragkopoulou_Katerina_Master thesisFragkopoulou_Katerina_Master thesis
Fragkopoulou_Katerina_Master thesis
 
Appreciating differences certificate
Appreciating differences certificateAppreciating differences certificate
Appreciating differences certificate
 
Alejandro Exarcheas-Ibarra's Personal Persona Project
Alejandro Exarcheas-Ibarra's Personal Persona ProjectAlejandro Exarcheas-Ibarra's Personal Persona Project
Alejandro Exarcheas-Ibarra's Personal Persona Project
 
на барикадах кенгіра
на барикадах кенгірана барикадах кенгіра
на барикадах кенгіра
 
Oracle sql material
Oracle sql materialOracle sql material
Oracle sql material
 
AFNetworking
AFNetworking AFNetworking
AFNetworking
 
E
EE
E
 
27 fcs157al3
27 fcs157al327 fcs157al3
27 fcs157al3
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Tour
 
Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorial
 

Semelhante a Mongo db

3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf
MarianJRuben
 

Semelhante a Mongo db (20)

MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
 
Mongo db
Mongo dbMongo db
Mongo db
 
Mongo DB
Mongo DBMongo DB
Mongo DB
 
lecture_34e.pptx
lecture_34e.pptxlecture_34e.pptx
lecture_34e.pptx
 
3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf
 
Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answers
 
Kalp Corporate MongoDB Tutorials
Kalp Corporate MongoDB TutorialsKalp Corporate MongoDB Tutorials
Kalp Corporate MongoDB Tutorials
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Mongodb By Vipin
Mongodb By VipinMongodb By Vipin
Mongodb By Vipin
 
Mongodb Introduction
Mongodb IntroductionMongodb Introduction
Mongodb Introduction
 
Mondodb
MondodbMondodb
Mondodb
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
 
Mongo learning series
Mongo learning series Mongo learning series
Mongo learning series
 
MongoDB
MongoDBMongoDB
MongoDB
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
Mongodb - NoSql Database
Mongodb - NoSql DatabaseMongodb - NoSql Database
Mongodb - NoSql Database
 
MongoDB NoSQL database a deep dive -MyWhitePaper
MongoDB  NoSQL database a deep dive -MyWhitePaperMongoDB  NoSQL database a deep dive -MyWhitePaper
MongoDB NoSQL database a deep dive -MyWhitePaper
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
The emerging world of mongo db csp
The emerging world of mongo db   cspThe emerging world of mongo db   csp
The emerging world of mongo db csp
 
Introduction to MongoDB.pptx
Introduction to MongoDB.pptxIntroduction to MongoDB.pptx
Introduction to MongoDB.pptx
 

Mais de Raghu nath

Ftp (file transfer protocol)
Ftp (file transfer protocol)Ftp (file transfer protocol)
Ftp (file transfer protocol)
Raghu nath
 
Javascript part1
Javascript part1Javascript part1
Javascript part1
Raghu nath
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Raghu nath
 
Selection sort
Selection sortSelection sort
Selection sort
Raghu nath
 
Binary search
Binary search Binary search
Binary search
Raghu nath
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
Raghu nath
 
Stemming algorithms
Stemming algorithmsStemming algorithms
Stemming algorithms
Raghu nath
 
Step by step guide to install dhcp role
Step by step guide to install dhcp roleStep by step guide to install dhcp role
Step by step guide to install dhcp role
Raghu nath
 
Network essentials chapter 4
Network essentials  chapter 4Network essentials  chapter 4
Network essentials chapter 4
Raghu nath
 
Network essentials chapter 3
Network essentials  chapter 3Network essentials  chapter 3
Network essentials chapter 3
Raghu nath
 
Network essentials chapter 2
Network essentials  chapter 2Network essentials  chapter 2
Network essentials chapter 2
Raghu nath
 
Network essentials - chapter 1
Network essentials - chapter 1Network essentials - chapter 1
Network essentials - chapter 1
Raghu nath
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
Raghu nath
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
Raghu nath
 
Linux Shell Scripting
Linux Shell ScriptingLinux Shell Scripting
Linux Shell Scripting
Raghu nath
 
Adv excel® 2013
Adv excel® 2013Adv excel® 2013
Adv excel® 2013
Raghu nath
 

Mais de Raghu nath (20)

Ftp (file transfer protocol)
Ftp (file transfer protocol)Ftp (file transfer protocol)
Ftp (file transfer protocol)
 
MS WORD 2013
MS WORD 2013MS WORD 2013
MS WORD 2013
 
Msword
MswordMsword
Msword
 
Ms word
Ms wordMs word
Ms word
 
Javascript part1
Javascript part1Javascript part1
Javascript part1
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Selection sort
Selection sortSelection sort
Selection sort
 
Binary search
Binary search Binary search
Binary search
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
 
Stemming algorithms
Stemming algorithmsStemming algorithms
Stemming algorithms
 
Step by step guide to install dhcp role
Step by step guide to install dhcp roleStep by step guide to install dhcp role
Step by step guide to install dhcp role
 
Network essentials chapter 4
Network essentials  chapter 4Network essentials  chapter 4
Network essentials chapter 4
 
Network essentials chapter 3
Network essentials  chapter 3Network essentials  chapter 3
Network essentials chapter 3
 
Network essentials chapter 2
Network essentials  chapter 2Network essentials  chapter 2
Network essentials chapter 2
 
Network essentials - chapter 1
Network essentials - chapter 1Network essentials - chapter 1
Network essentials - chapter 1
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
 
Linux Shell Scripting
Linux Shell ScriptingLinux Shell Scripting
Linux Shell Scripting
 
Perl
PerlPerl
Perl
 
Adv excel® 2013
Adv excel® 2013Adv excel® 2013
Adv excel® 2013
 

Último

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Último (20)

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 

Mongo db

  • 2. MongoDB is a document-oriented database, not a relational one. A document-oriented database replaces the concept of a “row” with a more flexible model, the “document.”
  • 3. MongoDB is intended to be a general-purpose database so aside from creating, reading, updating, and deleting data Indexing Aggregation Special collection types
  • 4. MongoDB is made up of databases which contain collections. A collection is made up of documents. Each document is made up of fields. Collections can be indexed, which improves lookup and sorting performance. Finally, when we get data from MongoDB we do so through a cursor whose actual execution is delayed until necessary.
  • 5. In JavaScript, for example, documents are represented as objects: { "greeting“ : "Hello, world!“ }
  • 6. This simple document contains a single key, "greeting“ , with a value of "Hello, world!“ . Most documents will be more complex than this simple one and often will contain multiple key/value pairs: { "greeting“ :"Hello, world!","foo":3 }
  • 7. The keys in a document are strings. Any UTF-8 character is allowed in a key, with a few notable exceptions: Keys must not contain the character 0 (the null character). This character is used to signify the end of a key
  • 8. The . and $ characters have some special properties and should be used only in certain circumstances, as described in later chapters. In general, they should be considered reserved, and drivers will complain if they are used inappropriately.
  • 9. MongoDB is type-sensitive and case-sensitive Collections: A collection is a group of documents. Dynamic Schemas: Collections have dynamic schemas . This means that the documents within a single col‐ lection can have any number of different “shapes.”
  • 10. {"greeting“ : "Hello, world!"} { "foo":5} Naming: A collection is identified by its name. Collection names can be any UTF-8 string, with a few restrictions: The empty string ("") is not a valid collection name
  • 11. Collection names may not contain the character 0 (the null character) because this delineates the end of a collection name.
  • 12. Getting and Starting MongoDB MongoDB is almost always run as a network server that clients can connect to and perform operations on $ mongod mongod --help for help and startup options.
  • 13. When run with no arguments, mongod will use the default data directory, /data/db/ (or datadb on the current volume on Windows). If the data directory does not already exist or is not writable, the server will fail to start. It is important to create the data directory (e.g., mkdir -p /data/db/ ) and to make sure your user has permission to write to the directory before starting MongoDB
  • 14. Running the Shell To start the shell, run the mongo executable: $Mongo MongoDB shell version : 2.4 . 0 connecting to : test >
  • 15. The shell is a full-featured JavaScript interpreter, capable of running arbitrary JavaScript programs. To illustrate this, let’s perform some basic math: >x =200 200 >x/5; 40
  • 16. A MongoDB Client To see the database db is currently assigned to, type in db and hit Enter: >db Test
  • 17. Basic Operations with the Shel CRUD: create, read, update, and delete to manipulate and view data in the shell.
  • 18. Data Types Basic Data Types Documents in MongoDB can be thought of as “JSON-like” in that they are conceptually similar to objects in JavaScript. JSON is a simple representation of data: the specification can be described in about one paragraph (their website proves it) and lists only six data types.
  • 19. The most common types are Null Dates Arrays Embedded documents
  • 21. Creating, Updating, and Deleting Documents Adding new documents to a collection • Removing documents from a collection • Updating existing documents • Choosing the correct level of safety versus speed for all of these operations
  • 22. Inserting and Saving Documents Inserts are the basic method for adding data to MongoDB. Batch Insert Batch inserts allow you to pass an array of documents to the database. Insert Validation MongoDB does minimal checks on data being inserted:
  • 23. Removing Documents Now that there’s data in our database, let’s delete it: Remove Speed Removing documents is usually a fairly quick operation. Updating Documents Setting a Write Concern
  • 24. Querying Find method is used to perform queries in MongoDB. Specifying Which Keys to Return Sometimes you do not need all of the key/value pairs in a document returned.
  • 25. Cursors The database returns results from find using a cursor.