I'd like to use multiple pre-save mongoose Middleware for a single schema, is this possible?
Example:
var schema = new Schema(..);
schema.pre('save', function(next) {
// do stuff
next();
});
schema.pre('save', function(next) {
// do another thing
next();
});
INDEED i can. I inspected the schema object and found the following property:
callQueue:
[ [ 'pre', [Object] ],
[ 'pre', [Object] ],
[ 'pre', [Object] ],
[ 'pre', [Object] ],
[ 'pre', [Object] ],
[ 'pre', [Object] ],
[ 'pre', [Object] ] ],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With