的
.save()是该模型的一个实例方法中,当
.create()直接从被呼叫
Model作为一个方法调用,在本质上静态的,拍摄对象作为第一参数。
var mongoose = require('mongoose');var notificationSchema = mongoose.Schema({ "datetime" : { type: Date, default: Date.now }, "ownerId":{ type:String }, "customerId" : { type:String }, "title" : { type:String }, "message" : { type:String }});var Notification = mongoose.model('Notification', notificationsSchema);function saveNotification1(data) { var notification = new Notification(data); notification.save(function (err) { if (err) return handleError(err); // saved! })}function saveNotification2(data) { Notification.create(data, function (err, small) { if (err) return handleError(err); // saved! })}将任何您想要的功能导出到外部。
有关Mongoose
Docs的更多信息,或考虑阅读
ModelMongoose
中的原型参考。



