Skip to content

feat: add model hook decorators - #15333

Merged
ephys merged 3 commits into
mainfrom
ephys/hook-decorators
Nov 26, 2022
Merged

ephys merged 3 commits into
mainfrom
ephys/hook-decorators

Conversation

@ephys

@ephys ephys commented Nov 25, 2022

Copy link
Copy Markdown
Member

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description Of Change

This PR adds the @sequelize/core/decorators-legacy import. Called decorators-legacy because these decorators are implemented using the legacy decorators proposal. Once TypeScript supports the new decorators proposal, we'll look into adding @sequelize/core/decorators

This PR adds the hook decorators from https://github.com/sequelize/sequelize-typescript/. More to come

@WikiRik WikiRik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/decorators/legacy/README.md Resolved
Comment thread test/unit/decorators/hooks.test.ts Resolved
Comment thread src/decorators/legacy/index.mjs Resolved
@ephys

ephys commented Nov 25, 2022

Copy link
Copy Markdown
Member Author

Associate is missing by accident but there are a bunch of decorators in sequelize-typescript that can't be used. For instance, @BeforeConnect can't be used on a model, the event is triggered on the Sequelize instance, so having a decorator for it isn't possible (or I'm missing something)

@WikiRik

WikiRik commented Nov 26, 2022

Copy link
Copy Markdown
Member

Yeah, I assumed so. I only looked at the validModelHooks list that we have

@ephys

ephys commented Nov 26, 2022

Copy link
Copy Markdown
Member Author

Added the missing tests & fixed what failed

@ephys
ephys requested a review from WikiRik November 26, 2022 11:40
@ephys ephys mentioned this pull request Nov 26, 2022
13 of 15 tasks
@ephys
ephys merged commit bd037c8 into main Nov 26, 2022
@ephys
ephys deleted the ephys/hook-decorators branch November 26, 2022 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants