update method
Update rows matching predicate with updates under ctx.
Returns count of updated rows.
Implementation
int update(
TxnContext ctx,
bool Function(Map<String, dynamic>) predicate,
Map<String, dynamic> updates,
Set<int> activeTransactions,
) {
int count = 0;
for (final chain in _chains.values) {
final visible = chain.visibleVersion(ctx);
if (visible == null) continue;
if (!predicate(visible.values)) continue;
// Write-write conflict check
_checkWriteConflict(chain.head, activeTransactions, ctx.txnId);
// Mark current head as deleted by this txn
chain.head.deletedByTxn = ctx.txnId;
// Create new version with updated values
final newValues = Map<String, dynamic>.from(visible.values)
..addAll(updates);
final newVersion = MvccRowVersion(
rowId: visible.rowId,
values: newValues,
createdByTxn: ctx.txnId,
prev: chain.head, // link to old version
);
chain.head = newVersion;
count++;
}
return count;
}