fzaninotto / mongoose-lifecycle

Plugin for Mongoose (Node.js ODM for MongoDB) adding lifecyle events on the model class
MIT License
94 stars 9 forks source link

feature request: afterCreate #1

Open 0xgeert opened 12 years ago

0xgeert commented 12 years ago

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

fzaninotto commented 12 years ago

I think the feature you're asking for is Plugins: http://mongoosejs.com/docs/plugins.html

robbrit commented 11 years ago

@gbrits: This is handled by the mongoose-lifecycle plugin: https://github.com/fzaninotto/mongoose-lifecycle