MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / DeleteResult

Class DeleteResult

pymongo/results.py:182–206  ·  view source on GitHub ↗

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`.

Source from the content-addressed store, hash-verified

180
181
182class 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
209class _BulkWriteResultBase(_WriteResult):

Callers 7

test_delete_resultMethod · 0.90
delete_oneMethod · 0.90
delete_manyMethod · 0.90
delete_oneMethod · 0.90
delete_manyMethod · 0.90

Calls

no outgoing calls

Tested by 1

test_delete_resultMethod · 0.72