upsert method
Inserts the row if no row with the same id exists, otherwise
patches the existing row with the keys in data. Soft-delete
column on data is honoured (the engine uses upsert to apply
pulled tombstones).
Caller supplies all sync metadata fields; the adapter does not populate them. Atomic with respect to transaction.
Added in 0.2.0 for the engine's pull pipeline.
Implementation
@override
Future<void> upsert(String table, Map<String, dynamic> data) async {
final rows =
_tables.putIfAbsent(table, () => <String, Map<String, dynamic>>{});
final id = data[SyncColumns.id] as String;
if (rows.containsKey(id)) {
rows[id]!.addAll(data);
} else {
rows[id] = Map<String, dynamic>.from(data);
}
}