results – Result class definitions#

Result class definitions.

class pymongo.results.BulkWriteResult(bulk_api_result, acknowledged)#

Create a BulkWriteResult instance.

Parameters:
  • bulk_api_result (dict[str, Any]) – A result dict from the bulk API

  • acknowledged (bool) – Was this write result acknowledged? If False then all properties of this object will raise InvalidOperation.

property acknowledged: bool#

Is this the result of an acknowledged write operation?

The acknowledged attribute will be False when using WriteConcern(w=0), otherwise True.

Note

If the acknowledged attribute is False all other attributes of this class will raise InvalidOperation when accessed. Values for other attributes cannot be determined if the write operation was unacknowledged.

See also

WriteConcern

property bulk_api_result: dict[str, Any]#

The raw bulk API result.

property deleted_count: int#

The number of documents deleted.

property inserted_count: int#

The number of documents inserted.

property matched_count: int#

The number of documents matched for an update.

property modified_count: int#

The number of documents modified.

property upserted_count: int#

The number of documents upserted.

property upserted_ids: dict[int, Any] | None#

A map of operation index to the _id of the upserted document.

class pymongo.results.DeleteResult(raw_result, acknowledged)#

The return type for delete_one() and delete_many()

Parameters:
  • raw_result (Mapping[str, Any]) –

  • acknowledged (bool) –

property acknowledged: bool#

Is this the result of an acknowledged write operation?

The acknowledged attribute will be False when using WriteConcern(w=0), otherwise True.

Note

If the acknowledged attribute is False all other attributes of this class will raise InvalidOperation when accessed. Values for other attributes cannot be determined if the write operation was unacknowledged.

See also

WriteConcern

property deleted_count: int#

The number of documents deleted.

property raw_result: Mapping[str, Any]#

The raw result document returned by the server.

class pymongo.results.InsertManyResult(inserted_ids, acknowledged)#

The return type for insert_many().

Parameters:
  • inserted_ids (list[Any]) –

  • acknowledged (bool) –

property acknowledged: bool#

Is this the result of an acknowledged write operation?

The acknowledged attribute will be False when using WriteConcern(w=0), otherwise True.

Note

If the acknowledged attribute is False all other attributes of this class will raise InvalidOperation when accessed. Values for other attributes cannot be determined if the write operation was unacknowledged.

See also

WriteConcern

property inserted_ids: list[Any]#

A list of _ids of the inserted documents, in the order provided.

Note

If False is passed for the ordered parameter to insert_many() the server may have inserted the documents in a different order than what is presented here.

class pymongo.results.InsertOneResult(inserted_id, acknowledged)#

The return type for insert_one().

Parameters:
  • inserted_id (Any) –

  • acknowledged (bool) –

property acknowledged: bool#

Is this the result of an acknowledged write operation?

The acknowledged attribute will be False when using WriteConcern(w=0), otherwise True.

Note

If the acknowledged attribute is False all other attributes of this class will raise InvalidOperation when accessed. Values for other attributes cannot be determined if the write operation was unacknowledged.

See also

WriteConcern

property inserted_id: Any#

The inserted document’s _id.

class pymongo.results.UpdateResult(raw_result, acknowledged)#

The return type for update_one(), update_many(), and replace_one().

Parameters:
  • raw_result (Optional[Mapping[str, Any]]) –

  • acknowledged (bool) –

property acknowledged: bool#

Is this the result of an acknowledged write operation?

The acknowledged attribute will be False when using WriteConcern(w=0), otherwise True.

Note

If the acknowledged attribute is False all other attributes of this class will raise InvalidOperation when accessed. Values for other attributes cannot be determined if the write operation was unacknowledged.

See also

WriteConcern

property matched_count: int#

The number of documents matched for this update.

property modified_count: int#

The number of documents modified.

property raw_result: Mapping[str, Any] | None#

The raw result document returned by the server.

property upserted_id: Any#

The _id of the inserted document if an upsert took place. Otherwise None.