Skip to content

A @Hook decorator would be great #88

Closed
@natesilva

Description

@natesilva

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions