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
feat: implement Model._UNSTABLE_destroyMany
#17031
Conversation
note to myself for when i have more time to work on this: the repository should be able to receive breaking changes during V7, so the getter on models should be prefixed with |
I included a fix for the deprecation notice discovered in #15934 (comment). Considering that the method changed already, I opted to removed |
Just as a sidenote; we can just remove TableNameOrModel in a next PR. We introduced it in the alphas, so no breaking change compared to v6. I did a quick replace and added additional tests in the query generator unit tests and only one is failing (bulkDeleteQuery with a limit set, since it will check for |
More thoughts on this: I started working on the paranoid code path for this function but I wanted to make it use So I think I should do the following in this PR:
And I think we should continue to slowly migrate model methods to the repository, implementing them using the new standards, then in v8 make them the default methods |
I think this is ready to be merged. I want to do the |
packages/core/src/dialects/abstract/query-generator-typescript.ts
Outdated
Show resolved
Hide resolved
Model.destroyMany
Model._UNSTABLE_destroyMany
Pull Request Checklist
Description Of Change
This PR implements #15459 for non-paranoid deletes, making it possible to delete multiple instances in one query:
Following PRs will implement
modelInstance.destroy
callRepository.destroy
saveMany
updateMany
restoreMany
Technical Notes
This PR also introduces a number of new practices:
repository
approach. The model delegates to the repository. As we slowly migrate everything to the repository, we'll one day be able to have a proper repository system that allows using the same entities in multiple databases.noHooks
as it's clearer for booleans to befalse
by default.hardDelete
.force
has been deprecated in favor ofhardDelete
, as what it does is clearer thanforce
(considering a paranoid delete is a soft delete)TableOrModel
, that aims to replaceTableNameOrModel
: This type supports repositories as welloptions
object, and makes it mutable, but only at the top level. All nested values are immutable. This immutability is only applied in development environments to avoid the overhead in production. This should greatly improve the performances, and means we can make our types readonly.destroy
method, I think the approach I'm going to take for the migration of model is to move the logic into model-repository method by method, but keep the old code as-in in model.js, and in v8 make model.js call model-repository.