applyTransactionUpdateAndCollectKeys method
Set
applyTransactionUpdateAndCollectKeys(
- BsatnRowList deletes,
- BsatnRowList inserts,
- EventContext context
Apply transaction update and return the set of touched primary keys
Used for touch-based optimistic confirmation. Returns all primary keys that were inserted, updated, or deleted in this transaction.
Implementation
Set<dynamic> applyTransactionUpdateAndCollectKeys(
BsatnRowList deletes,
BsatnRowList inserts,
EventContext context,
) {
final changes = _applyChanges(deletes, inserts);
_emitChanges(changes, context);
if (isEvent) {
_rowsByPrimaryKey.clear();
_rows.clear();
}
final touchedKeys = <dynamic>{};
for (final row in changes.inserted) {
final pk = decoder.getPrimaryKey(row);
if (pk != null) touchedKeys.add(pk);
}
for (final row in changes.deleted) {
final pk = decoder.getPrimaryKey(row);
if (pk != null) touchedKeys.add(pk);
}
for (final (_, newRow) in changes.updated) {
final pk = decoder.getPrimaryKey(newRow);
if (pk != null) touchedKeys.add(pk);
}
return touchedKeys;
}