delete<_Model extends _RepositoryModel> method

  1. @override
Future<bool> delete<_Model extends _RepositoryModel>(
  1. _Model instance, {
  2. Query? query,
})

Remove a model from SQLite and the remoteProvider

Implementation

@override
Future<bool> delete<_Model extends _RepositoryModel>(
  _Model instance, {
  Query? query,
}) async {
  query = (query ?? Query()).copyWith(action: QueryAction.delete);
  logger.finest('#delete: $query');

  final rowsDeleted = await sqliteProvider.delete<_Model>(
    instance,
    query: query,
    repository: this,
  );
  memoryCacheProvider.delete<_Model>(instance, query: query);

  try {
    await remoteProvider.delete<_Model>(instance, query: query, repository: this);
  } on ClientException catch (e) {
    logger.warning('#delete client failure: $e');
  } on SocketException catch (e) {
    logger.warning('#delete socket failure: $e');
  }

  // ignore: unawaited_futures
  if (autoHydrate) hydrate<_Model>(query: query);

  return rowsDeleted > 0;
}