Node.js 为什么是";这";猫鼬保存前钩子和保存后钩子中的关键字不同?

Node.js 为什么是";这";猫鼬保存前钩子和保存后钩子中的关键字不同?,node.js,mongoose,Node.js,Mongoose,这是我的代码的相关片段 MySchema .pre('save', function (next) { var self = this; console.log(self); return next(); }); MySchema .post('save', function (next) { var self = this; console.log(self); }); 出于某种原因,在这种情况下,pre-save钩子会给出一个适当的

这是我的代码的相关片段

MySchema
  .pre('save', function (next) {
    var self = this;
    console.log(self);
    return next();
  });

MySchema
  .post('save', function (next) {
    var self = this;
    console.log(self);
  });
出于某种原因,在这种情况下,pre-save钩子会给出一个适当的对象

{ farm: 557ce790a893e4e0118059e3,
  _id: 557ce791a893e4e011805a35,
  privileges:
   [ { instanceId: 557ce790a893e4e0118059bb,
       access: 5,
       modelType: 'User' } ],
  public: 0,
  properties: { crop: 'No Crop', name: 'Pirani Tract 50' },
  geometry: { type: 'Polygon', coordinates: [ [Object] ] } }
但是post save钩子只是记录日志

{ domain: null,
  _events:
   { save: [ [Function: notify], [Function] ],
     isNew: [Function: notify],
     init: [Function] },
  _maxListeners: 0 }
中间件将文档作为参数接收,而不是
pre
中间件接收的
next
流控制回调参数

MySchema
  .post('save', function(doc) {
    console.log(doc);
  });