Skip to content

Add getCrudTransactions() returning an async generator #693

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

Merged
merged 5 commits into from
Aug 20, 2025

Conversation

simolus3
Copy link
Contributor

Sometimes, users want a batch of data to upload while also ensuring that that batch respects transaction boundaries. At the moment, we don't really have APIs for that, because:

  • getCrudBatch() returns a batch of items with a flexible size limit, but doesn't respect transaction boundaries (so it's possible to accidentally upload half of a transaction).
  • getNextCrudTransaction() returns a complete transaction, but nothing more. It will also always return the oldest transaction, so you can't call getNextCrudTransaction() multiple times to get more than one.

This adds getCrudTransactions(), an async iterable that starts with the oldest transaction and then keeps on yielding more transactions until the iterator is closed. This gives users a tool to compose batches with flexible sizes while still ensuring everything is grouped by transactions.

Copy link

changeset-bot bot commented Aug 14, 2025

🦋 Changeset detected

Latest commit: 75c3e2c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@powersync/common Minor
@powersync/node Minor
@powersync/react-native Minor
@powersync/web Minor
@powersync/adapter-sql-js Patch
@powersync/op-sqlite Patch
@powersync/tanstack-react-query Patch
@powersync/diagnostics-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me. Left some comments to consider with React Native.

stevensJourney
stevensJourney previously approved these changes Aug 18, 2025
@simolus3 simolus3 merged commit c910c66 into main Aug 20, 2025
9 checks passed
@simolus3 simolus3 deleted the get-crud-transactions branch August 20, 2025 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants