beforeFind hook not called when model is included
See original GitHub issueWhen doing
Model.findOne({ include: [ ModelWithBeforeFindHook ] }).then(result => {
...
});
The beforeFind hook is not called, and there is no other hook to use in this scenario.
In my beforeFind hook I add a few includes that I want to always load with this model, so I’m trying to have this happen also when the model is included.
I’m expecting beforeFind to be called, if this is not desired then I think a new hook should be added to solve this.
Discuss 😃
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Sequelize afterFind hook not executed when querying with ...
My question is: Why are the hooks not being executed when the model -- on which the hooks are specified -- is included...
Read more >afterFind Hook not called with correct values or not ...
I have a smart field role on the user model. This field is populated with a query to userRole. To improve performance I...
Read more >Hooks
Hooks (also known as lifecycle events), are functions which are called before and after calls in sequelize are executed. For example, if you...
Read more >beforeGet - Velo API Reference
A hook that is triggered before a get() operation. The beforeGet() hook runs when the get() function is called. The hook does not...
Read more >Instance Methods | Objection.js
Creates a query builder for this model instance. ... For deletes there is no instance for which to call the hook, except when...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ohh, just forgot, in my use case I needed to trigger the
afterFindhook in the included model.Right now what I’m doing is defining two
hasManyassociations in a common model manually defined by me (ex: ABMemberships) instead of thebelongsToMany. That, withseparatein mind for thehasManydid the trick.