o
    ?8¾\Š  ã                   @   st   d Z ddlmZ G dd„ deƒZG dd„ deƒZG dd„ deƒZG d	d
„ d
eƒZG dd„ deƒZG dd„ deƒZ	dS )zResult class definitions.é    )ÚInvalidOperationc                   @   s0   e Zd ZdZdZdd„ Zdd„ Zedd„ ƒZd	S )
Ú_WriteResultz$Base class for write result classes.)Ú__acknowledgedc                 C   s
   || _ d S ©N©Ú_WriteResult__acknowledged)ÚselfÚacknowledged© r
   úA/var/www/html/env/lib/python3.10/site-packages/pymongo/results.pyÚ__init__   s   
z_WriteResult.__init__c                 C   s   | j s
td|f ƒ‚dS )z8Raise an exception on property access if unacknowledged.zwA value for %s is not available when the write is unacknowledged. Check the acknowledged attribute to avoid this error.N)r   r   )r   Úproperty_namer
   r
   r   Ú_raise_if_unacknowledged   s
   ýÿz%_WriteResult._raise_if_unacknowledgedc                 C   ó   | j S )aB  Is this the result of an acknowledged write operation?

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

        .. note::
          If the :attr:`acknowledged` attribute is ``False`` all other
          attibutes of this class will raise
          :class:`~pymongo.errors.InvalidOperation` when accessed. Values for
          other attributes cannot be determined if the write operation was
          unacknowledged.

        .. seealso::
          :class:`~pymongo.write_concern.WriteConcern`
        r   ©r   r
   r
   r   r	   $   s   z_WriteResult.acknowledgedN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   Úpropertyr	   r
   r
   r
   r   r      s    r   c                       ó0   e Zd ZdZdZ‡ fdd„Zedd„ ƒZ‡  ZS )ÚInsertOneResultzKThe return type for :meth:`~pymongo.collection.Collection.insert_one`.
    )Ú__inserted_idr   c                    ó   || _ tt| ƒ |¡ d S r   )Ú_InsertOneResult__inserted_idÚsuperr   r   )r   Úinserted_idr	   ©Ú	__class__r
   r   r   >   ó   zInsertOneResult.__init__c                 C   r   )zThe inserted document's _id.)r   r   r
   r
   r   r   B   ó   zInsertOneResult.inserted_id)	r   r   r   r   r   r   r   r   Ú__classcell__r
   r
   r   r   r   8   ó    r   c                       r   )ÚInsertManyResultzLThe return type for :meth:`~pymongo.collection.Collection.insert_many`.
    )Ú__inserted_idsr   c                    r   r   )Ú_InsertManyResult__inserted_idsr   r$   r   )r   Úinserted_idsr	   r   r
   r   r   N   r    zInsertManyResult.__init__c                 C   r   )a@  A list of _ids of the inserted documents, in the order provided.

        .. note:: If ``False`` is passed for the `ordered` parameter to
          :meth:`~pymongo.collection.Collection.insert_many` the server
          may have inserted the documents in a different order than what
          is presented here.
        )r&   r   r
   r
   r   r'   R   s   	zInsertManyResult.inserted_ids)	r   r   r   r   r   r   r   r'   r"   r
   r
   r   r   r$   H   r#   r$   c                       sT   e Zd ZdZdZ‡ fdd„Zedd„ ƒZedd„ ƒZed	d
„ ƒZ	edd„ ƒZ
‡  ZS )ÚUpdateResultz¿The return type for :meth:`~pymongo.collection.Collection.update_one`,
    :meth:`~pymongo.collection.Collection.update_many`, and
    :meth:`~pymongo.collection.Collection.replace_one`.
    ©Ú__raw_resultr   c                    r   r   )Ú_UpdateResult__raw_resultr   r(   r   ©r   Ú
raw_resultr	   r   r
   r   r   f   r    zUpdateResult.__init__c                 C   r   ©z/The raw result document returned by the server.)r+   r   r
   r
   r   r-   j   r!   zUpdateResult.raw_resultc                 C   s&   |   d¡ | jdurdS | j dd¡S )z0The number of documents matched for this update.Úmatched_countNr   Ún)r   Úupserted_idr+   Úgetr   r
   r
   r   r/   o   s   

zUpdateResult.matched_countc                 C   ó   |   d¡ | j d¡S ©a  The number of documents modified.

        .. note:: modified_count is only reported by MongoDB 2.6 and later.
          When connected to an earlier server version, or in certain mixed
          version sharding configurations, this attribute will be set to
          ``None``.
        Úmodified_countÚ	nModified©r   r+   r2   r   r
   r
   r   r5   w   ó   
	zUpdateResult.modified_countc                 C   r3   )z^The _id of the inserted document if an upsert took place. Otherwise
        ``None``.
        r1   Úupsertedr7   r   r
   r
   r   r1   ƒ   s   
zUpdateResult.upserted_id)r   r   r   r   r   r   r   r-   r/   r5   r1   r"   r
   r
   r   r   r(   ^   s    


r(   c                       s<   e Zd ZdZdZ‡ fdd„Zedd„ ƒZedd„ ƒZ‡  Z	S )	ÚDeleteResultz€The return type for :meth:`~pymongo.collection.Collection.delete_one`
    and :meth:`~pymongo.collection.Collection.delete_many`r)   c                    r   r   )Ú_DeleteResult__raw_resultr   r:   r   r,   r   r
   r   r   ’   r    zDeleteResult.__init__c                 C   r   r.   )r;   r   r
   r
   r   r-   –   r!   zDeleteResult.raw_resultc                 C   s   |   d¡ | j dd¡S )ú The number of documents deleted.Údeleted_countr0   r   )r   r;   r2   r   r
   r
   r   r=   ›   s   
zDeleteResult.deleted_count)
r   r   r   r   r   r   r   r-   r=   r"   r
   r
   r   r   r:   Œ   s    
r:   c                       sx   e Zd ZdZdZ‡ fdd„Zedd„ ƒZedd„ ƒZed	d
„ ƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZ‡  ZS )ÚBulkWriteResultz-An object wrapper for bulk API write results.)Ú__bulk_api_resultr   c                    s   || _ tt| ƒ |¡ dS )a<  Create a BulkWriteResult instance.

        :Parameters:
          - `bulk_api_result`: A result dict from the bulk API
          - `acknowledged`: Was this write result acknowledged? If ``False``
            then all properties of this object will raise
            :exc:`~pymongo.errors.InvalidOperation`.
        N)Ú!_BulkWriteResult__bulk_api_resultr   r>   r   )r   Úbulk_api_resultr	   r   r
   r   r   §   s   	zBulkWriteResult.__init__c                 C   r   )zThe raw bulk API result.)r@   r   r
   r
   r   rA   ³   r!   zBulkWriteResult.bulk_api_resultc                 C   r3   )z!The number of documents inserted.Úinserted_countÚ	nInserted©r   r@   r2   r   r
   r
   r   rB   ¸   ó   
zBulkWriteResult.inserted_countc                 C   r3   )z.The number of documents matched for an update.r/   ÚnMatchedrD   r   r
   r
   r   r/   ¾   rE   zBulkWriteResult.matched_countc                 C   r3   r4   rD   r   r
   r
   r   r5   Ä   r8   zBulkWriteResult.modified_countc                 C   r3   )r<   r=   ÚnRemovedrD   r   r
   r
   r   r=   Ð   rE   zBulkWriteResult.deleted_countc                 C   r3   )z!The number of documents upserted.Úupserted_countÚ	nUpsertedrD   r   r
   r
   r   rH   Ö   rE   zBulkWriteResult.upserted_countc                 C   s,   |   d¡ | jrtdd„ | jd D ƒƒS dS )z=A map of operation index to the _id of the upserted document.Úupserted_idsc                 s   s    � | ]}|d  |d fV  qdS )ÚindexÚ_idNr
   )Ú.0Úupsertr
   r
   r   Ú	<genexpr>á   s   € ÿz/BulkWriteResult.upserted_ids.<locals>.<genexpr>r9   N)r   r@   ÚdictrA   r   r
   r
   r   rJ   Ü   s   
ÿÿzBulkWriteResult.upserted_ids)r   r   r   r   r   r   r   rA   rB   r/   r5   r=   rH   rJ   r"   r
   r
   r   r   r>   ¢   s$    





r>   N)
r   Úpymongo.errorsr   Úobjectr   r   r$   r(   r:   r>   r
   r
   r
   r   Ú<module>   s   $.