upsertBroadcasts method
Inserts or updates a batch of Broadcast events within a single transaction.
Used primarily during historical catch-up syncs after retrieving missing events from the server to minimize disk I/O overhead.
Implementation
@override
Future<void> upsertBroadcasts(List<Broadcast> broadcasts) async {
await _db.transaction((txn) async {
final batch = txn.batch();
for (final msg in broadcasts) {
batch.insert(
Broadcast.tableName,
msg.toMap(),
conflictAlgorithm: ConflictAlgorithm.replace,
);
}
await batch.commit(noResult: true);
});
}