标签:
官方文档代码:
1 var schema = new Schema(..); 2 schema.post(‘save‘, function (doc) { 3 console.log(‘this fired after a document was saved‘); 4 }); 5 6 var Model = mongoose.model(‘Model‘, schema); 7 8 var m = new Model(..); 9 m.save(function (err) { 10 console.log(‘this fires after the `post` hook‘); 11 });
大概意思是m在保存时会触发post监听的事件会被触发,
不明白post和pre有什么区别,
个人猜测,
1、触发的时间不同
标签:
原文地址:http://www.cnblogs.com/suoking/p/5258784.html