-
-
Save vdeturckheim/c6dd297d34d9786531260df30b2b9282 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const proto = Object.getPrototypeOf(Mongoose); | |
const exec = proto.Query.prototype.exec; | |
proto.Query.prototype.exec = wrapAsync(exec); // wrapping exec will wrap most mongoose call | |
const Model = proto.Model; // we still need to wrap save and remove here since they do not work like the other methods in mongoose. | |
const remove = Model.prototype.remove; | |
Model.prototype.remove = wrapAsync(remove, 'mongoose.remove'); | |
const save = Model.prototype.save; | |
Model.prototype.save = wrapAsync(save, 'mongoose.save'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment