Node.js Inserting Documents


For inserting a new document in the collection, we create a object of the schema.

var Auto = require('models/auto')
var autoObj = new Auto({
    name: "NewName", 
    countOf: 10

We save it like the following, insertedAuto) {
    if (err) return console.error(err);
    // output: Hello this is NewName and I have counts of 10

This will insert a new document in the collection