Inserting Documents

suggest change

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

autoObj.save(function(err, insertedAuto) {
    if (err) return console.error(err);
    insertedAuto.speak();
    // output: Hello this is NewName and I have counts of 10
});

This will insert a new document in the collection

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents