CrdtMutationRecorder class
Persists additional CRDT rows after a mutating ORM operation completes.
Callbacks receive the underlying database (not the CRDT proxy) and the active transaction. Use that database for follow-up inserts so work is not wrapped again by the proxy.
- Available extensions
Constructors
- CrdtMutationRecorder(Database db, {required OfflineSyncDatabaseContext context, required UuidValue? persistentUserId})
- Creates a CrdtMutationRecorder instance.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- persistentUserId → UuidValue?
-
The user ID to use for all CRDT operations. This should only be used for
databases operating on the client side, where all data is for the same user.
Otherwise, the user ID must be passed through the transaction.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
syncTables
→ List<
Table> -
The list of tables to sync with CRDT.
no setter
Methods
-
afterInsert<
T extends TableRow> (List< T> insertedRows, Transaction transaction, {ProjectionAttemptsByField attempts = const {}}) → Future<void> - Insert the CRDT metadata for the inserted rows.
-
afterReinsert<
T extends TableRow> (List< T> reinsertedRows, Transaction transaction) → Future<void> - Records a row insertion that reused an existing tombstoned domain row.
-
afterUpdate<
T extends TableRow> (List< T> updatedRows, List<Column> ? columns, Transaction transaction, {bool projectionUnchanged = false, Map<MergeRowKey, Map< domainBeforeUpsert = const {}}) → Future<String, Object?> >void> - Records CRDT field metadata for updated rows.
-
deletedRowIds<
T extends TableRow> (List< T> rows, Transaction transaction) → Future<Set< UuidValue> > - IDs of the given rows that are soft-deleted.
-
ensureInitialized(
) → Future< void> - Ensures the recorder is ready without clearing live per-session caches.
-
getOrCreateSpace(
UuidValue userId) → Future< OfflineSyncSpace> - Returns the OfflineSyncSpace for the given user ID, creating it when needed.
-
initialize(
) → Future< void> - Initializes the CRDT recorder.
-
insteadOfDelete<
T extends TableRow> (List< T> deletedRows, Transaction transaction) → Future<void> - Soft-deletes rows by recording a tombstone instead of removing them.
-
isCrdtTracked<
T extends TableRow> ([Table? table]) → bool - Whether the given table is tracked by CRDT.
-
lockCurrentUser(
Transaction transaction) → Future< void> -
Available on CrdtMutationRecorder, provided by the CrdtMergeRecorderExtension extension
Locks the current user row so merges can serialize with other work. -
mergeChanges(
CrdtMergeSet mergeSet, Transaction transaction) → Future< void> -
Available on CrdtMutationRecorder, provided by the CrdtMergeRecorderExtension extension
Merges remote CRDT changes into the current database. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
planLocalInserts<
T extends TableRow> (List< T> rows, Transaction transaction) → Future<({ProjectionAttemptsByField attempts, List< T> rows})> - Plans FK/unique projection for rows that are about to be inserted.
-
planLocalUpdates<
T extends TableRow> (List< T> rows, List<Column> ? columns, Transaction transaction, {bool restoring = false}) → Future<({bool projectionUnchanged, List< T> rows})> - Plans FK/unique projection for rows that are about to be updated.
-
prepareLocalUpsert<
T extends TableRow> (List< T> rows, List<Column> conflictColumns, List<Column> ? updateColumns, Transaction transaction) → Future<({Map< MergeRowKey, Map< domain, bool projectionUnchanged})>String, Object?> > - Captures the materialized values before an upsert so its accepted writes can replace old attempted values without authoring unchanged projections.
-
projectCurrent(
String tableName, Set< UuidValue> rowIds, Transaction transaction) → Future<void> - Recomputes FK/unique projection for currently stored rows.
-
recordSyncCheckpoint(
UuidValue userId, UuidValue otherNodeId, Hlc syncedHlc) → Future< void> -
Records the latest acknowledged sync checkpoint for
otherNodeId. -
spaceForQueries(
Transaction? transaction) → OfflineSyncSpace? -
Returns the user scoping CRDT visibility for queries, or null when no
user is associated with
transactionand no persistent user exists. -
tableIdForName(
String tableName) → int? -
Returns the local CrdtSchemaTable id for
tableName, or null when the table is not registered for CRDT synchronization. -
toString(
) → String -
A string representation of this object.
inherited
-
validateAuthoredRows<
T extends TableRow> (List< T> rows, List<Column> ? columns, {ProjectionAttemptsByField attempts = const {}}) → void - Validates unprojected ORM writes, or projected inserts with their attempts.
-
withForeignKeyInsertDefaults<
T extends TableRow> (List< T> rows) → List<T> - Supplies fixed UUID FK defaults before building a local upsert. SQLite's upsert builder cannot emit DEFAULT inside VALUES. Resolve the same schema default that an insert would use, leaving other fields to the ORM.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited