SeaQL / sea-orm

🐚 An async & dynamic ORM for Rust
https://www.sea-ql.org/SeaORM/
Apache License 2.0
6.94k stars 483 forks source link

[ADD]: Addition of delete many #615

Open AbhijithGanesh opened 2 years ago

AbhijithGanesh commented 2 years ago

Summary

Delete the row(s) on db at the same time returning the data of deleted row(s).

Motivation

Various other delete methods, this method is a good method to implement as it makes the ORM more complete.

Additional Information

Rough idea is that we need two new methods in DeleteMany, https://github.com/SeaQL/sea-orm/blob/af235168db3a675e889974a34799890350be00e4/src/executor/delete.rs#L34-L46, namely one & all which return single model & array of models respectively. For database support RETURNING, https://docs.rs/sea-orm/0.6.0/sea_orm/query/trait.ConnectionTrait.html#method.support_returning, it will use RETURNING syntax on delete statement to get the data of deleted models.

AbhijithGanesh commented 2 years ago

@billy1624 can you please assign this to me?

billy1624 commented 2 years ago

Assigned! :P

billy1624 commented 2 years ago

Hey @AbhijithGanesh,

Rough idea is that we need two new methods in DeleteMany, namely one & all which return single model & array of models respectively.

https://github.com/SeaQL/sea-orm/blob/af235168db3a675e889974a34799890350be00e4/src/executor/delete.rs#L34-L46

For database support RETURNING, it will use RETURNING syntax on delete statement to get the data of deleted models.