//The insert() Method
db.COLLECTION_NAME.insert(document)
//e.g.
//Here mycol is our collection name, as created in the previous chapter.
// If the collection doesn't exist in the database, then MongoDB will create this collection and
//then insert a document into it.
//In the inserted document, if we don't specify the _id parameter,
//then MongoDB assigns a unique ObjectId for this document.
//_id is 12 bytes hexadecimal number unique for every document in a collection.
//12 bytes are divided as follows −
db.mycol.insert({
_id: ObjectId(7df78ad8902c),
title: 'MongoDB Overview',
})
//insert multiple
db.post.insert([
{
title: 'MongoDB Overview',
description: 'MongoDB is no sql database',
},
{
title: 'NoSQL Database',
description: "NoSQL database doesn't have tables",
by: 'tutorials point',
url: 'http://www.tutorialspoint.com',
]
}
])