update method
Update rows matching where. Returns affected count.
Implementation
Future<int> update(
bool Function(Row) where,
Map<String, dynamic> updates,
) async {
int count = 0;
for (final pid in await _allPageIds()) {
final rows = await _readPageRows(pid);
bool changed = false;
for (final row in rows) {
if (where(row)) {
for (final entry in indexes.entries) {
final old = row[entry.key];
if (old != null) entry.value.delete(old, row.id);
}
for (final e in updates.entries) {
row.values[e.key] = e.value;
}
for (final entry in indexes.entries) {
final nv = row[entry.key];
if (nv != null) entry.value.insert(nv, row.id);
}
count++;
changed = true;
}
}
if (changed) await _writePageRows(pid, rows);
}
return count;
}