官网上的例子看不懂, 这个是类似监听事件之类触发的函数么?
var schema = new Schema(..);
schema.pre('save', function (next) {
// do stuff
next();
});
var schema = new Schema(..);
schema.pre('save', true, function (next, done) {
// calling next kicks off the next middleware in parallel
next();
doAsync(done);
});
http://mongoosejs.com/docs/middleware.html
.path() 也很难懂啊:
schema.path('name') // returns a SchemaType
schema.path('name', Number) // changes the schemaType of `name` to Number