performDocumentDelete method

  1. @override
Future<void> performDocumentDelete(
  1. DocumentDeleteRequest request
)
override

Implementation

@override
Future<void> performDocumentDelete(DocumentDeleteRequest request) async {
  final document = request.document;
  final collection = document.parent;

  //
  // Validate IDs
  //
  final documentId = _validateDocumentId(document.documentId);
  final collectionId = _validateCollectionId(collection.collectionId);

  //
  // Send HTTP request
  //
  final response = await _httpRequest(
    'DELETE',
    '/$collectionId/_doc/$documentId',
  );

  switch (response.status) {
    case HttpStatus.found:
      return;
    case HttpStatus.notFound:
      if (request.mustExist) {
        throw DatabaseException.notFound(request.document);
      }
      return;
    default:
      throw response.error;
  }
}