MongoDB - Insert Data

Posted by Professionaluser under Sql Server category on | Points: 40 | Views : 128
insert() method in MongoDB can be used to add a document to the collection. MongoDB creates a collection automatically if you specify the collection name that does not exist in database.

>db.Person.Insert ({"name" : "XYZ"}
, "PhoneNum" : 1234567890
, "MailID" : ""

Above code creates the collection with name "Person"and also inserts a document into it with fields Name, PhoneNum, and MailID

Comments or Responses

Login to post response