destructiveLocalSyncFromRemote<_Model extends T> method
When invoked, local instances that exist in sqliteProvider and memoryCacheProvider but do not exist in the remoteProvider are destroyed. The data from the remoteProvider should not be paginated and must be complete from a single request.
Implementation
Future<List<_Model>> destructiveLocalSyncFromRemote<_Model extends T>({Query? query}) async {
query = (query ?? Query()).copyWith(action: QueryAction.get);
logger.finest('#get: $_Model $query');
final remoteResults = await remoteProvider.get<_Model>(query: query, repository: this);
final localResults = await sqliteProvider.get<_Model>(query: query, repository: this);
final toDelete = localResults.where((r) => !remoteResults.contains(r));
for (final deletableModel in toDelete) {
await sqliteProvider.delete(deletableModel);
memoryCacheProvider.delete(deletableModel);
}
return await storeRemoteResults<_Model>(remoteResults);
}