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
Adding updateMany and deleteMany Methods to Remult repository #221
Comments
Thanks. How would you handle lifecycle events such as validation, saving etc... Also, in the updateMany - you indicated that you want to return an entity, I think it makes sense to return void, or number of rows affected |
|
I wanted to add my perspective to this conversation if I may. update/delete in bulk would be an amazing feature, and having lifecycle events to reflect bulk CUD would really complete it. Lets say i have this contrived example where i want to call an external service prior to the record being saved:
whereas it would be great if i could perform it in bulk as part of the lifecycle:
in terms of return type, i personally think it would be useful to have a list of success/failures, e.g
So the whole thing might look like this:
(PS, I realise I can achieve all of this by structuring the code differently but am just trying to explain why i think it would be a useful feature) |
Let me add a small thing as well: // was my 2 cents 😉 |
@jycouet maybe a additional boolean parameter to give the option to fail the whole batch if any in the batch fail? |
We've implemented npm i remult@exp Please check it out and let me know if you have any comments. Currently, it's defined as a transaction, so it all succeeds or all fails. |
That's great! Is it possible to add it to the API as well? |
Working on it |
Hi @meni3a I've created a new Can you check it out and see if it's ok?
|
@noam-honig Looks good! |
Released in version 0.26.0: |
Description:
I would like to propose an enhancement to Remult by adding
updateMany
anddeleteMany
methods to the repository interface, which can be implemented across various database types.Currently, developers are required to perform these operations individually using their IDs. This feature request aims to streamline the process by allowing developers to update or delete multiple entities in a single query.
Benefits:
Improved Performance: With the ability to update or delete multiple entities in a single query, performance improvements can be realized, especially when dealing with large datasets. This reduces the overhead of making multiple round-trips to the database.
Simplified Code: The addition of updateMany and deleteMany methods would lead to more concise and readable code. Developers would no longer need to write repetitive code for iterating through each entity and performing updates or deletions one by one.
Proposed API:
The text was updated successfully, but these errors were encountered: