Skip to content
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

Allow returning in batch operations #3320

Open
rubenferreira97 opened this issue Oct 30, 2024 · 1 comment
Open

Allow returning in batch operations #3320

rubenferreira97 opened this issue Oct 30, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@rubenferreira97
Copy link

rubenferreira97 commented Oct 30, 2024

Is your feature request related to a problem? Please describe.
Sometimes I need to get columns that were inserted in a batch insert, like in createReturning.
Example: Get generated columns like id, computed columns like createdAt.

Currently bulkCreate returns Future<void>.

Future<void> createArticles(List<ArticleCompanion> articles) async {
  return database.managers.article.bulkCreate(
    (f) => articles,
  );
}

Describe the solution you'd like

  • Change Future<void> bulkCreate(...) to Future<Iterable<PrimaryKeyType>> bulkCreate(...). This might be a slight breaking change but since you can assign Iterable<PrimaryKeyType> to void it should be fine.
  • Add Future<Iterable<ArticleData>> bulkCreateReturning(...).

I don't know the inner batch implementation but I think it should be feasible to implement this.

@rubenferreira97 rubenferreira97 added the enhancement New feature or request label Oct 30, 2024
@simolus3
Copy link
Owner

I agree that this would be nice to have 👍 It is possible, but definitely a lot of work since it touches all backends + isolates + web workers for the transport. And then we have to provide the API for both the core Batch as well as the manager APIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants