delete method
Delete rows matching where. Returns affected count.
Implementation
Future<int> delete(bool Function(Row) where) async {
int count = 0;
for (final pid in await _allPageIds()) {
final rows = await _readPageRows(pid);
final remaining = <Row>[];
bool changed = false;
for (final row in rows) {
if (where(row)) {
for (final entry in indexes.entries) {
final v = row[entry.key];
if (v != null) entry.value.delete(v, row.id);
}
count++;
changed = true;
} else {
remaining.add(row);
}
}
if (changed) {
await _writePageRows(pid, remaining);
meta.rowCount = (meta.rowCount - count).clamp(0, 999999999);
}
}
return count;
}