Closed
Description
There are several ways to add hooks, but they need your Model
to be added to a Sequelize instance first. It isn’t very declarative.
It would be great if there was a @Hook
decorator. Something like:
@Table
class Book extends Model<Book> {
// (bunch of @Columns etc.)
@Hook('beforeCreate')
static reticulateSplines(instance: Book) {
// do beforeCreate hook stuff here
}
@Hook('afterDestroy')
static herdLlamas(instance: Book) {
// do afterDestroy hook stuff here
}
}
Is this in the works? I could try to write something. The decorator would store information using the reflect-metadata
system and then something like initializeHooks
would be called from the addModels
method.