exists<_Model extends RestModel> method

  1. @override
Future<bool> exists<_Model extends RestModel>({
  1. Query? query,
  2. ModelRepository<RestModel>? repository,
})

Whether a model instance is present. null is returned when existence is unknown. The model instance is not hydrated in the function output; a bool variant (e.g. List<bool>, Map<TModel, bool>) should be returned.

Implementation

@override
Future<bool> exists<_Model extends RestModel>({query, repository}) async {
  final url = urlForModel<_Model>(query);
  if (url == null) return false;

  logger.fine('GET $url');

  final resp = await client.get(Uri.parse(url), headers: headersForQuery(query));
  return statusCodeIsSuccessful(resp.statusCode);
}