New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
omitHook #14053
Comments
I have found a stackoverlow on similar question , see if it can help you , or else please let me know.here is the link : https://stackoverflow.com/questions/20707199/how-to-ignore-hooks |
Can't promise this will be implemented, your best shot would be to open a PR If this were to be implemented, I think an API that mimics // this already exists today
Model.destroy({ hooks: false });
// only run specific hooks
Model.destroy({ hooks: ['beforeDestroy'] });
// exclude some hooks
Model.destroy({ hooks: { exclude: ['beforeDestroy'] } }); |
Agree with the API as proposed by @ephys |
The change is not too hard but a lot of code needs to be changed in many different files. But the code deciding whether the hook should or shouldn't run is duplicated in many places, such as here: https://github.com/sequelize/sequelize/blob/main/src/model.js#L1813 Best solution IMO would be to always pass an option bag to runHooks, then runHooks decides whether the hook will run based on The typings would also need to be updated here: https://github.com/sequelize/sequelize/blob/main/src/model.d.ts#L750 We'd need to write an extensive amount of tests to ensure the option works in each place, which is the really painful part |
my respects, it's an incredible library but I got lost very easily jeje I've been trying to understand the code for 2 months and I have experience in js you get lost in so much code haha, consult us it would be better to start separating by files as much as possible for the debug |
good morning I find myself working with this incredible library in my microservice system and I observe that there is no way to omit a universal hook. There is a possibility that you might consider adding an option to skip a specific hook I will give a very used use case in my little service
the hooks works fine when I call the destroy function
example controller
Model example
I would like only in that function to avoid the destroy hooks
The text was updated successfully, but these errors were encountered: