onWriteEntries method
Saves entries in this order and returns them with ids
(StoredLogEntry.id): increasing in save order and never reused (in
SQLite, INTEGER PRIMARY KEY AUTOINCREMENT). Entries are already in
stored form (LogEntry.withoutLiveObjects). A batch is best saved in
one transaction; the sink passes the next one only after this one
completes. The base sends LogEntriesAdded.
Implementation
@override
Future<List<StoredLogEntry>> onWriteEntries(List<LogEntry> entries) async {
final stored = List<StoredLogEntry>.unmodifiable([for (final entry in entries) StoredLogEntry(_nextId++, entry)]);
stored.forEach(_insert);
final limit = this.limit;
if (limit != null && _entries.length > limit) {
// The base sends this after the LogEntriesAdded of this write.
reportChange(LogEntriesRemovedById(_removeOldest(_entries.length - limit)));
}
return stored;
}