MongoDB - fetch/retrieve data from a collection

Professionaluser
Posted by Professionaluser under Sql Server category on | Points: 40 | Views : 1064
MongoDB returns/retrieves data from a collection by using the below method.
>db.createcollection("CollectionName") -- creates a collection ( properties are capped, autoIndexId, size and max)
>db.CollectionName.Insert("name" : "XYZ", "PhoneNum" : 1234567890, "MailID" : "xyz123@gmail.com")
>db.CollectionName.find()

Output
{ "name" : "XYZ", "PhoneNum" : 1234567890, "MailID" : "xyz123@gmail.com"}


Note: find() returns all documents in a collection if any filters are not specified

Comments or Responses

Login to post response