多个猫鼬预保存中间件

Ary*_*mon 7 mongoose node.js

我想为单个架构使用多个预先保存的mongoose中间件,这可能吗?

例:

var schema = new Schema(..);

schema.pre('save', function(next) {
  // do stuff
  next();
});
schema.pre('save', function(next) {
  // do another thing
  next();
});
Run Code Online (Sandbox Code Playgroud)

Ary*_*mon 18

我可以.我检查了架构对象并找到了以下属性:

  callQueue: 
   [ [ 'pre', [Object] ],
     [ 'pre', [Object] ],
     [ 'pre', [Object] ],
     [ 'pre', [Object] ],
     [ 'pre', [Object] ],
     [ 'pre', [Object] ],
     [ 'pre', [Object] ] ],
Run Code Online (Sandbox Code Playgroud)