history method
The record's change log, oldest first. Empty when history is off.
Implementation
Future<List<DVHistoryEntry>> history(Object id) async {
if (historyPolicy == null) return const <DVHistoryEntry>[];
// Scoped by the tenant each entry was written under, which is the
// scope's: another tenant's record with the same key is another record.
final List<Map<String, Object?>> rows = await database.query(
'SELECT * FROM $historyTable WHERE record_key = ? '
'${scope == null ? '' : 'AND tenant = ? '}'
'ORDER BY record_version ASC',
<Object?>[id, if (scope != null) _tenant(null)],
);
return rows.map(_entryFromRow).toList(growable: false);
}