The return type for :meth:`~pymongo.collection.Collection.delete_one` and :meth:`~pymongo.collection.Collection.delete_many` and as part of :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.
| 180 | |
| 181 | |
| 182 | class DeleteResult(_WriteResult): |
| 183 | """The return type for :meth:`~pymongo.collection.Collection.delete_one` |
| 184 | and :meth:`~pymongo.collection.Collection.delete_many` |
| 185 | and as part of :meth:`~pymongo.mongo_client.MongoClient.bulk_write`. |
| 186 | """ |
| 187 | |
| 188 | __slots__ = ("__raw_result",) |
| 189 | |
| 190 | def __init__(self, raw_result: Mapping[str, Any], acknowledged: bool) -> None: |
| 191 | self.__raw_result = raw_result |
| 192 | super().__init__(acknowledged) |
| 193 | |
| 194 | def __repr__(self) -> str: |
| 195 | return f"{self.__class__.__name__}({self.__raw_result!r}, acknowledged={self.acknowledged})" |
| 196 | |
| 197 | @property |
| 198 | def raw_result(self) -> Mapping[str, Any]: |
| 199 | """The raw result document returned by the server.""" |
| 200 | return self.__raw_result |
| 201 | |
| 202 | @property |
| 203 | def deleted_count(self) -> int: |
| 204 | """The number of documents deleted.""" |
| 205 | self._raise_if_unacknowledged("deleted_count") |
| 206 | return self.__raw_result.get("n", 0) |
| 207 | |
| 208 | |
| 209 | class _BulkWriteResultBase(_WriteResult): |
no outgoing calls