• Save
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
130
On Slideshare
130
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. MongoDB Reading/findingDocumentReading/finding Document Use Casedetailed
  • 2. Reading/finding in DocumentSyntaxdb.collection.find( <query>,<projection> )<query> argument corresponds tothe WHERE statement, and<projection> argument correspondsto the list of fields to select from theresult 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 thedata 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 bereturned from thecollection
  • 7. Thanks for Watchingfeedbackappreciated…………………………