overwriteAllRawData method

  1. @override
Future<void> overwriteAllRawData(
  1. List<Map<String, dynamic>> data, {
  2. String? userId,
})
override

Overwrite all existing data with a new set of raw data maps. This is used during schema migrations after transforming the data.

Implementation

@override
Future<void> overwriteAllRawData(List<Map<String, dynamic>> data, {String? userId}) async {
  if (userId != null && userId.isNotEmpty) {
    _storage.remove(userId);
  } else {
    _storage.clear();
  }
  for (final raw in data) {
    final entity = fromMap(raw);
    _storage.putIfAbsent(entity.userId, () => {})[entity.id] = entity;
  }
}