storeRemoteResults<_Model extends _RepositoryModel> method
Save response results to SQLite.
Implementation
@protected
@visibleForTesting
Future<List<_Model>> storeRemoteResults<_Model extends _RepositoryModel>(
List<_Model> models) async {
final modelIds = models.map((m) => sqliteProvider.upsert<_Model>(m, repository: this));
final results = await Future.wait<int?>(modelIds, eagerError: true);
MapEntry modelWithPrimaryKey(index, id) {
final model = models[index];
model.primaryKey = id;
return MapEntry(index, model);
}
return results.asMap().map(modelWithPrimaryKey).values.toList().cast<_Model>();
}