performDocumentUpdate method

  1. @override
Future<void> performDocumentUpdate(
  1. DocumentUpdateRequest request
)
override

Updates by using read and upsert operations inside a transaction.

Implementation

@override
Future<void> performDocumentUpdate(DocumentUpdateRequest request) async {
  await _wait();
  const ArbitraryTreeSchema().checkTreeIsValid(request.data);
  final key = _keyFromDocument(request.document);
  final oldValue = _values[key];
  if (oldValue == null) {
    throw DatabaseException.notFound(request.document);
  }

  // Is this a patch?
  var data = request.data;
  if (request.isPatch) {
    final patchedData = Map<String, Object>.from(oldValue.data);
    patchedData.addAll(data);
    data = patchedData;
  }

  // Update
  _values[key] = _Value(request.data);
}