插入文件

为了在集合中插入新文档,我们创建了一个模式对象。

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

我们保存如下

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

这将在集合中插入新文档