Skip to content

Conversation

@natesilva
Copy link
Contributor

@natesilva natesilva commented Aug 17, 2017

I had to re-do the pull request after I botched the original branch. The only change is that this centralizes the hook implementation logic into the hooks services file.

Fixes #88, replaces #97.

@codecov-io
Copy link

codecov-io commented Aug 17, 2017

Codecov Report

Merging #101 into master will increase coverage by 0.64%.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #101 +/- ## ========================================= + Coverage 95.66% 96.3% +0.64%  ========================================= Files 66 99 +33 Lines 761 893 +132 Branches 107 114 +7 ========================================= + Hits 728 860 +132  Misses 11 11 Partials 22 22
Impacted Files Coverage Δ
lib/annotations/hooks/AfterCreate.ts 100% <100%> (ø)
...notations/hooks/BeforeFindAfterExpandIncludeAll.ts 100% <100%> (ø)
lib/annotations/hooks/BeforeDestroy.ts 100% <100%> (ø)
lib/annotations/hooks/AfterRestore.ts 100% <100%> (ø)
lib/annotations/hooks/AfterBulkUpdate.ts 100% <100%> (ø)
lib/annotations/hooks/AfterDestroy.ts 100% <100%> (ø)
lib/annotations/hooks/BeforeBulkDelete.ts 100% <100%> (ø)
lib/annotations/hooks/AfterBulkRestore.ts 100% <100%> (ø)
lib/annotations/hooks/AfterBulkDelete.ts 100% <100%> (ø)
lib/annotations/hooks/BeforeCount.ts 100% <100%> (ø)
... and 57 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1cfa77...2fa0702. Read the comment docs.

@RobinBuschmann RobinBuschmann merged commit 93f5c24 into sequelize:master Aug 17, 2017
@natesilva
Copy link
Contributor Author

Thank you!

@natesilva natesilva deleted the feature/hooks branch August 17, 2017 17:21
@RobinBuschmann
Copy link
Member

Thank you for implementing this. It's a great feature!

@RobinBuschmann
Copy link
Member

RobinBuschmann commented Aug 26, 2017

I've made a beta release, in which this feature is included now :)

npm install sequelize-typescript@0.5.0-beta.3

@thormengkheang
Copy link

@RobinBuschmann can I use an async function like this?

 @BeforeUpdate @BeforeCreate static async hashPassword(instance: User) { // this will be called when an instance is created or updated instance.password = await bcrypt.hash(instance.password, 10); }
@natesilva
Copy link
Contributor Author

@mengkheang Yes. A hook function may return a Promise, so async functions are fine. http://docs.sequelizejs.com/manual/tutorial/hooks.html#declaring-hooks

@thormengkheang
Copy link

@natesilva thank for the explaining :)

@RobinBuschmann
Copy link
Member

sequelize-typescript@0.5.0 is released now 🎉

@natesilva
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants