SeaQL / sea-orm

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

Divide the insert_many logic to an InsertMany struct to support returning from it. #1862

Open dvtkrlbs opened 1 year ago

dvtkrlbs commented 1 year ago

Motivation

Currently there does not seem to be any way of inserting many rows and immediately returning it. The use case for this when using database calculated columns such as id columns.

Proposed Solutions

Similar to UpdateMany introduce an InsertMany struct that has the exec_with_returning function that returns the Vec of Model impls

Current Workarounds

Immediately selecting the rows back which might not be possible always. Or the worse but always working workaround is inserting in a loop.

I would be happy to try to implement my proposed solution with some guidance.

DMaxter commented 11 months ago

I am also looking forward for some feature like this. The way I'm currently using it I can only retrieve the latest ID, and would be useful to get all the IDs that were inserted.

LonelyPale commented 11 months ago

Looking forward to this feature.

0-don commented 10 months ago

yes this is a very important feature, would love this aswell

mohamedalichelbi commented 1 month ago

+1