remove method

Future<MutationResult> remove(
  1. String key, [
  2. RemoveOptions? options
])

Remove an existing document from the collection.

Implementation

Future<MutationResult> remove(String key, [RemoveOptions? options]) async {
  options ??= const RemoveOptions();
  final id = _documentId(key);
  final cas = options.cas ?? InternalCas.zero;
  final timeout = _mutationTimeout(options);

  final response = options.usesLegacyDurability
      ? await _connection.removeWithLegacyDurability(
          RemoveWithLegacyDurability(
            id: id,
            cas: cas,
            timeout: timeout,
            persistTo: options.durabilityPersistTo,
            replicateTo: options.durabilityReplicateTo,
            partition: 0,
            opaque: 0,
          ),
        )
      : await _connection.remove(
          RemoveRequest(
            id: id,
            cas: cas,
            timeout: timeout,
            durabilityLevel: options.durabilityLevel,
            partition: 0,
            opaque: 0,
          ),
        );

  return MutationResult(
    cas: response.cas,
    token: response.token,
  );
}