mongoose-lifecycle
mongoose-lifecycle copied to clipboard
feature request: afterCreate
Consider the use-case where a model instance needs to do some initialization DIRECTLY after it has been created, based on the properties that particular instance is created with.
This would enable controllers to interact with the just created model instance, while being able to rely on the logic defined in afterCreate to have fired.
As of now, there's no hook to support this afaik. (e.g; pre(init) only works on the init of a schema not a schema instance).
It would be great if this could somehow be supported.
Best, Geert-Jan
I think the feature you're asking for is Plugins: http://mongoosejs.com/docs/plugins.html
@gbrits: This is handled by the mongoose-lifecycle plugin: https://github.com/fzaninotto/mongoose-lifecycle