SlideShare a Scribd company logo
MongoDB Reading/finding
Document
Reading/finding Document Use Case
detailed
Reading/finding in Document
Syntax
db.collection.find( <query>,
<projection> )
<query> argument corresponds to
the WHERE statement, and
<projection> argument corresponds
to the list of fields to select from the
result set.
findOne()
Find the first record in the document
> db.user.findOne()
{
"_id" : ObjectId("513c6ef1cfce9090d3fd8b1d"),
"date" : ISODate("2013-03-10T11:30:50.555Z"),
"remarks" : [
{
"name" : "anish",
"rate" : "good"
},
{
"name" : "nath",
"rate" : "bad"
}
],
"uName" : "anish"
}
findOne() : specify which key to return
• Find the first record in the document and return only “_id”
> db.user.findOne({},{"_id":1})
{ "_id" : ObjectId("513c6ef1cfce9090d3fd8b1d") }
• Find the first record in the document and return only
“_id” and date
> db.user.findOne({},{"_id":1,"date":1})
{
"_id" : ObjectId("513c6ef1cfce9090d3fd8b1d"),
"date" : ISODate("2013-03-10T11:30:50.555Z")
}
• Find the first record in the document and return all the
data except the “_id” field
> db.user.findOne({},{"_id":0})
{
"date" : ISODate("2013-03-10T11:30:50.555Z"),
"remarks" : [
{
"name" : "anish",
"rate" : "good"
},
{
"name" : "nath",
"rate" : "bad"
}
],
"uName" : "anish"
}
finding in Subdocument
>db.user.find(
{"remarks.name":"anish" })
{ "_id" :
ObjectId("513c6ef1cfce9090d3fd8b1d"),
"date" : ISODate("2013-03-
10T11:30:50.555Z"), "remarks" : [ {
"name
" : "anish", "rate" : "good" }, {
"name" : "nath", "rate" : "bad" } ],
"uName" : "anish" }
findOne()/find()
• Summary on <K,boolean>
specify <“k”,0> or <“K”,1>
to show/hide data to be
returned from the
collection
Thanks for Watching
feedback
appreciated………………
…………

More Related Content

PDF
ORMLite Android
PDF
Green dao
PPTX
GreenDao Introduction
ODP
Mongo indexes
PPT
Fast querying indexing for performance (4)
PDF
greenDAO
PDF
Indexing and Query Optimizer (Mongo Austin)
PDF
Green dao
ORMLite Android
Green dao
GreenDao Introduction
Mongo indexes
Fast querying indexing for performance (4)
greenDAO
Indexing and Query Optimizer (Mongo Austin)
Green dao

What's hot (20)

PPTX
Indexing and Query Optimizer (Aaron Staple)
PPTX
Indexing & Query Optimization
PPTX
20150812 高中coding營 windows 10 app
PDF
Error based blind sqli
PPTX
Indexing with MongoDB
PPTX
MongoDB and Indexes - MUG Denver - 20160329
PPTX
Indexing and Query Optimization
PDF
MongoDB World 2016: Deciphering .explain() Output
PPTX
Indexing In MongoDB
ODP
Postgresql Server Programming
PPTX
Reducing Development Time with MongoDB vs. SQL
ODP
2011 Mongo FR - Indexing in MongoDB
PPTX
ObjectBox - The new Mobile Database
PPTX
Basic crud operation
PDF
Data access 2.0? Please welcome: Spring Data!
PDF
NDC London 2013 - Mongo db for c# developers
PDF
Indexing and Query Optimizer
PDF
4시간만에 따라해보는 Windows 10 앱 개발 샘플코드
PDF
An introduction into Spring Data
PPTX
Webinar: Index Tuning and Evaluation
Indexing and Query Optimizer (Aaron Staple)
Indexing & Query Optimization
20150812 高中coding營 windows 10 app
Error based blind sqli
Indexing with MongoDB
MongoDB and Indexes - MUG Denver - 20160329
Indexing and Query Optimization
MongoDB World 2016: Deciphering .explain() Output
Indexing In MongoDB
Postgresql Server Programming
Reducing Development Time with MongoDB vs. SQL
2011 Mongo FR - Indexing in MongoDB
ObjectBox - The new Mobile Database
Basic crud operation
Data access 2.0? Please welcome: Spring Data!
NDC London 2013 - Mongo db for c# developers
Indexing and Query Optimizer
4시간만에 따라해보는 Windows 10 앱 개발 샘플코드
An introduction into Spring Data
Webinar: Index Tuning and Evaluation
Ad

Viewers also liked (9)

PPTX
Redes sociales
PDF
Pensar o humano, amar o mundo
PPS
PDF
A crise na educação
PPTX
LA ADICCIÓN AL INTERNET
PPTX
Presentación power point zurich 2011 (modificada por gema manzano)
DOC
Presentación de proyecto.seleccionador de piezas
PPTX
Mateos garcía manuel actividad tema 1
PDF
Educação após Auschwitz
Redes sociales
Pensar o humano, amar o mundo
A crise na educação
LA ADICCIÓN AL INTERNET
Presentación power point zurich 2011 (modificada por gema manzano)
Presentación de proyecto.seleccionador de piezas
Mateos garcía manuel actividad tema 1
Educação após Auschwitz
Ad

Similar to Mongo db readingdocumentusecases (20)

PDF
PPS
MongoDB crud
PDF
Mdb dn 2016_06_query_primer
PPTX
MongoDB Knowledge share
PPTX
UNIT-1 MongoDB.pptx
KEY
MongoDB at GUL
PDF
Starting with MongoDB
PPTX
Mongo db queries
PDF
Mongo db basics
PPTX
Mongo Nosql CRUD Operations
PPTX
PDF
full stack modul 5, mongodb,webpack,front-end,back-end
PPTX
introtomongodb
PPTX
PPTX
Introduction to MongoDB
PPTX
Mongo db basic installation
PPTX
No SQL DB lecture showing structure and syntax
PDF
Slide perkenalan dengan dasar MongoDB-query
PDF
Mongo DB schema design patterns
ODP
MongoDB - A Document NoSQL Database
MongoDB crud
Mdb dn 2016_06_query_primer
MongoDB Knowledge share
UNIT-1 MongoDB.pptx
MongoDB at GUL
Starting with MongoDB
Mongo db queries
Mongo db basics
Mongo Nosql CRUD Operations
full stack modul 5, mongodb,webpack,front-end,back-end
introtomongodb
Introduction to MongoDB
Mongo db basic installation
No SQL DB lecture showing structure and syntax
Slide perkenalan dengan dasar MongoDB-query
Mongo DB schema design patterns
MongoDB - A Document NoSQL Database

Recently uploaded (20)

PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Computing-Curriculum for Schools in Ghana
PDF
01-Introduction-to-Information-Management.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
master seminar digital applications in india
PPTX
Pharma ospi slides which help in ospi learning
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Final Presentation General Medicine 03-08-2024.pptx
Supply Chain Operations Speaking Notes -ICLT Program
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
VCE English Exam - Section C Student Revision Booklet
Microbial diseases, their pathogenesis and prophylaxis
Computing-Curriculum for Schools in Ghana
01-Introduction-to-Information-Management.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Microbial disease of the cardiovascular and lymphatic systems
Final Presentation General Medicine 03-08-2024.pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
202450812 BayCHI UCSC-SV 20250812 v17.pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
master seminar digital applications in india
Pharma ospi slides which help in ospi learning
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...

Mongo db readingdocumentusecases

  • 2. Reading/finding in Document Syntax db.collection.find( <query>, <projection> ) <query> argument corresponds to the WHERE statement, and <projection> argument corresponds to the list of fields to select from the result set.
  • 3. findOne() Find the first record in the document > db.user.findOne() { "_id" : ObjectId("513c6ef1cfce9090d3fd8b1d"), "date" : ISODate("2013-03-10T11:30:50.555Z"), "remarks" : [ { "name" : "anish", "rate" : "good" }, { "name" : "nath", "rate" : "bad" } ], "uName" : "anish" }
  • 4. findOne() : specify which key to return • Find the first record in the document and return only “_id” > db.user.findOne({},{"_id":1}) { "_id" : ObjectId("513c6ef1cfce9090d3fd8b1d") } • Find the first record in the document and return only “_id” and date > db.user.findOne({},{"_id":1,"date":1}) { "_id" : ObjectId("513c6ef1cfce9090d3fd8b1d"), "date" : ISODate("2013-03-10T11:30:50.555Z") } • Find the first record in the document and return all the data except the “_id” field > db.user.findOne({},{"_id":0}) { "date" : ISODate("2013-03-10T11:30:50.555Z"), "remarks" : [ { "name" : "anish", "rate" : "good" }, { "name" : "nath", "rate" : "bad" } ], "uName" : "anish" }
  • 5. finding in Subdocument >db.user.find( {"remarks.name":"anish" }) { "_id" : ObjectId("513c6ef1cfce9090d3fd8b1d"), "date" : ISODate("2013-03- 10T11:30:50.555Z"), "remarks" : [ { "name " : "anish", "rate" : "good" }, { "name" : "nath", "rate" : "bad" } ], "uName" : "anish" }
  • 6. findOne()/find() • Summary on <K,boolean> specify <“k”,0> or <“K”,1> to show/hide data to be returned from the collection