Skip to content

Commit b5b995a

Browse files
committed
Add example to docs
1 parent 3468b38 commit b5b995a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

packages/powersync_core/lib/src/database/powersync_db_mixin.dart

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,26 @@ mixin PowerSyncDatabaseMixin implements SqliteConnection {
544544
/// stream until that point as completed.
545545
///
546546
/// This can be used to upload multiple transactions in a single batch, e.g.
547-
/// with:AbortController
547+
/// with:
548+
///
549+
/// ```dart
550+
/// CrudTransaction? lastTransaction;
551+
/// final batch = <CrudEntry>[];
552+
///
553+
/// await for (final transaction in powersync.nextCrudTransactions()) {
554+
/// batch.addAll(transaction.crud);
555+
/// lastTransaction = transaction;
556+
///
557+
/// if (batch.length > 100) {
558+
/// break;
559+
/// }
560+
/// }
561+
///
562+
/// if (batch.isNotEmpty) {
563+
/// await uploadBatch(batch);
564+
/// lastTransaction!.complete();
565+
/// }
566+
/// ```
548567
///
549568
/// If there is no local data to upload, the stream emits a single `onDone`
550569
/// event.

0 commit comments

Comments
 (0)