Asynchronous Mongoose Defaults

This is not in the documentation, but I'm trying to figure out how to set asynchronous defaults using Mongoose. I see the setup model.pre("save", function(next){}), but I don’t know how to mutate the fields in the model that is currently saved. Can Mongoose associate this with a saved item?

+5
source share
1 answer

Yes, in middleware, it thisrefers to a model instance at runtime.

+3
source

All Articles