码迷,mamicode.com
首页 > 其他好文 > 详细

mongoose post方法总结and疑点

时间:2016-03-09 17:19:51      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:

官方文档代码:

 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、触发的时间不同

mongoose post方法总结and疑点

标签:

原文地址:http://www.cnblogs.com/suoking/p/5258784.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!