performDocumentUpsert method

  1. @override
Future<void> performDocumentUpsert (
  1. DocumentUpsertRequest request
)
override

Implementation

@override
Future<void> performDocumentUpsert(DocumentUpsertRequest request) async {
  final document = request.document;
  final collection = document.parent;
  final collectionId = _validateCollectionId(collection.collectionId);
  final documentId = _validateDocumentId(document.documentId);

  //
  // Dispatch request
  //
  final apiResponse = await _apiRequest(
    method: 'PUT',
    path: '/1/indexes/$collectionId/$documentId',
    bodyJson: request.data,
    isWrite: true,
  );

  //
  // Handle error
  //
  final error = apiResponse.error;
  if (error != null) {
    throw error;
  }
}