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" : "xyz@gmail.com"
)
Above code creates the collection with name "Person"and also inserts a document into it with fields Name, PhoneNum, and MailID