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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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: d8f305f

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

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.

1 participant