Removes an existing document. Failing if the document does not exist. Args: key (str): Key for the document to remove. opts (:class:`~couchbase.options.RemoveOptions`): Optional parameters for this operation. **kwargs (Dict[str, Any]): keyword arguments t
(self,
key, # type: str
*opts, # type: RemoveOptions
**kwargs, # type: Dict[str, Any]
)
| 519 | return self._impl.replace(req, obs_handler) |
| 520 | |
| 521 | def remove(self, |
| 522 | key, # type: str |
| 523 | *opts, # type: RemoveOptions |
| 524 | **kwargs, # type: Dict[str, Any] |
| 525 | ) -> MutationResult: |
| 526 | """Removes an existing document. Failing if the document does not exist. |
| 527 | |
| 528 | Args: |
| 529 | key (str): Key for the document to remove. |
| 530 | opts (:class:`~couchbase.options.RemoveOptions`): Optional parameters for this operation. |
| 531 | **kwargs (Dict[str, Any]): keyword arguments that can be used in place or to |
| 532 | override provided :class:`~couchbase.options.RemoveOptions` |
| 533 | |
| 534 | Returns: |
| 535 | :class:`~couchbase.result.MutationResult`: An instance of :class:`~couchbase.result.MutationResult`. |
| 536 | |
| 537 | Raises: |
| 538 | :class:`~couchbase.exceptions.DocumentNotFoundException`: If the document does not exist on the |
| 539 | server. |
| 540 | |
| 541 | Examples: |
| 542 | |
| 543 | Simple remove operation:: |
| 544 | |
| 545 | bucket = cluster.bucket('travel-sample') |
| 546 | collection = bucket.scope('inventory').collection('airline') |
| 547 | |
| 548 | res = collection.remove('airline_10') |
| 549 | |
| 550 | |
| 551 | Simple remove operation with options:: |
| 552 | |
| 553 | from couchbase.durability import DurabilityLevel, ServerDurability |
| 554 | from couchbase.options import RemoveOptions |
| 555 | |
| 556 | # ... other code ... |
| 557 | |
| 558 | durability = ServerDurability(level=DurabilityLevel.MAJORITY) |
| 559 | res = collection.remove('airline_10', RemoveOptions(durability=durability)) |
| 560 | |
| 561 | """ |
| 562 | instruments = self._impl.observability_instruments |
| 563 | with ObservableRequestHandler.create(KeyValueOperationType.Remove, instruments) as obs_handler: |
| 564 | req = self._impl.request_builder.build_remove_request(key, obs_handler, *opts, **kwargs) |
| 565 | return self._impl.remove(req, obs_handler) |
| 566 | |
| 567 | def touch(self, |
| 568 | key, # type: str |
no test coverage detected