performDocumentInsert method

  1. @override
Future<void> performDocumentInsert(
  1. DocumentInsertRequest request
)
override

Inserts by using read and upsert operations inside a transaction.

Implementation

@override
Future<void> performDocumentInsert(DocumentInsertRequest request) async {
  await _wait();
  const ArbitraryTreeSchema().checkTreeIsValid(request.data);
  final document = request.document ?? request.collection.newDocument();
  if (request.onDocument != null) {
    request.onDocument(document);
  }
  final key = _keyFromDocument(document);
  if (_values.containsKey(key)) {
    throw DatabaseException.found(document);
  }
  _values[key] = _Value(request.data);
}