
    [jV!                        d Z ddlmZ ddlmZmZmZmZ ddlm	Z	  G d d          Z
 G d de
          Z G d	 d
e
          Z G d de
          Z G d de
          Z G d de
          ZdS )zResult class definitions.    )annotations)AnyMappingOptionalcast)InvalidOperationc                  F    e Zd ZdZdZddZdd	ZddZedd            Z	dS )_WriteResultz$Base class for write result classes.)__acknowledgedacknowledgedboolreturnNonec                    || _         d S N_WriteResult__acknowledged)selfr   s     S/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/pymongo/results.py__init__z_WriteResult.__init__   s    *    strc                0    | j         j         d| j         dS )N())	__class____name__r   r   s    r   __repr__z_WriteResult.__repr__   s!    .)BBD,?BBBBr   property_namec                :    | j         st          d| d          dS )z8Raise an exception on property access if unacknowledged.zA value for zi is not available when the write is unacknowledged. Check the acknowledged attribute to avoid this error.N)r   r   )r   r    s     r   _raise_if_unacknowledgedz%_WriteResult._raise_if_unacknowledged"   s?    " 	"}     	 	r   c                    | j         S )aC  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
          attributes 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   s    r   r   z_WriteResult.acknowledged,   s    " ""r   N)r   r   r   r   r   r   )r    r   r   r   )r   r   )
r   
__module____qualname____doc__	__slots__r   r   r"   propertyr    r   r   r
   r
      s        ..#I+ + + +C C C C    # # # X# # #r   r
   c                  H     e Zd ZdZdZd fd	ZddZedd            Z xZ	S )InsertOneResultzFThe return type for :meth:`~pymongo.collection.Collection.insert_one`.)__inserted_idinserted_idr   r   r   r   r   c                X    || _         t                                          |           d S r   )_InsertOneResult__inserted_idsuperr   )r   r.   r   r   s      r   r   zInsertOneResult.__init__E   s)    (&&&&&r   r   c                @    | j         j         d| j        d| j         dS Nr   z, acknowledged=r   )r   r   r0   r   r   s    r   r   zInsertOneResult.__repr__I   s.    ~&bb);bbdN_bbb	
r   c                    | j         S )zThe inserted document's _id.)r0   r   s    r   r.   zInsertOneResult.inserted_idN   s     !!r   )r.   r   r   r   r   r   r$   r   r   )
r   r%   r&   r'   r(   r   r   r)   r.   __classcell__r   s   @r   r,   r,   @   s|        PP"I' ' ' ' ' '
 
 
 

 " " " X" " " " "r   r,   c                  H     e Zd ZdZdZd fd	ZddZedd            Z xZ	S )InsertManyResultzGThe return type for :meth:`~pymongo.collection.Collection.insert_many`.)__inserted_idsinserted_ids	list[Any]r   r   r   r   c                X    || _         t                                          |           d S r   )_InsertManyResult__inserted_idsr1   r   )r   r;   r   r   s      r   r   zInsertManyResult.__init__Y   s)    *&&&&&r   r   c                @    | j         j         d| j        d| j         dS r3   )r   r   r>   r   r   s    r   r   zInsertManyResult.__repr__]   s.    ~&cc)<cctO`ccc	
r   c                    | j         S )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   s    r   r;   zInsertManyResult.inserted_idsb   s     ""r   )r;   r<   r   r   r   r   r$   )r   r<   )
r   r%   r&   r'   r(   r   r   r)   r;   r6   r7   s   @r   r9   r9   T   s|        QQ#I' ' ' ' ' '
 
 
 

 # # # X# # # # #r   r9   c                       e Zd ZdZdZd fdZdd
Zedd            Zedd            Z	edd            Z
edd            Z xZS )UpdateResultzThe return type for :meth:`~pymongo.collection.Collection.update_one`,
    :meth:`~pymongo.collection.Collection.update_many`, and
    :meth:`~pymongo.collection.Collection.replace_one`.
    __raw_result
raw_resultOptional[Mapping[str, Any]]r   r   c                X    || _         t                                          |           d S r   )_UpdateResult__raw_resultr1   r   r   rE   r   r   s      r   r   zUpdateResult.__init__v   )    &&&&&&r   r   r   c                @    | j         j         d| j        d| j         dS r3   )r   r   rH   r   r   s    r   r   zUpdateResult.__repr__z   -    .)ddD,=ddPTPaddddr   c                    | j         S z/The raw result document returned by the server.)rH   r   s    r   rE   zUpdateResult.raw_result}          r   intc                    |                      d           | j        dS | j        J | j                            dd          S )z0The number of documents matched for this update.matched_countNr   n)r"   upserted_idrH   getr   s    r   rR   zUpdateResult.matched_count   sN     	%%o666'1 ,,, $$S!,,,r   c                    |                      d           | j        J t          t          | j                            d                    S )!The number of documents modified.modified_countN	nModified)r"   rH   r   rP   rU   r   s    r   rX   zUpdateResult.modified_count   sI     	%%&6777 ,,,C*..{;;<<<r   r   c                r    |                      d           | j        J | j                            d          S )z^The _id of the inserted document if an upsert took place. Otherwise
        ``None``.
        rT   Nupserted)r"   rH   rU   r   s    r   rT   zUpdateResult.upserted_id   s>    
 	%%m444 ,,, $$Z000r   )rE   rF   r   r   r$   )r   rF   r   rP   r5   )r   r%   r&   r'   r(   r   r   r)   rE   rR   rX   rT   r6   r7   s   @r   rB   rB   n   s         
 "I' ' ' ' ' 'e e e e ! ! ! X! - - - X- = = = X= 1 1 1 X1 1 1 1 1r   rB   c                  `     e Zd ZdZdZd fd	ZddZedd            Zedd            Z	 xZ
S )DeleteResultzThe return type for :meth:`~pymongo.collection.Collection.delete_one`
    and :meth:`~pymongo.collection.Collection.delete_many`
    rC   rE   Mapping[str, Any]r   r   r   r   c                X    || _         t                                          |           d S r   )_DeleteResult__raw_resultr1   r   rI   s      r   r   zDeleteResult.__init__   rJ   r   r   c                @    | j         j         d| j        d| j         dS r3   )r   r   ra   r   r   s    r   r   zDeleteResult.__repr__   rL   r   c                    | j         S rN   )ra   r   s    r   rE   zDeleteResult.raw_result   rO   r   rP   c                b    |                      d           | j                            dd          S ) The number of documents deleted.deleted_countrS   r   )r"   ra   rU   r   s    r   rf   zDeleteResult.deleted_count   s1     	%%o666 $$S!,,,r   )rE   r_   r   r   r   r   r$   )r   r_   r\   )r   r%   r&   r'   r(   r   r   r)   rE   rf   r6   r7   s   @r   r^   r^      s          "I' ' ' ' ' 'e e e e ! ! ! X! - - - X- - - - -r   r^   c                       e Zd ZdZdZd fd	Z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 xZS )BulkWriteResultz-An object wrapper for bulk API write results.)__bulk_api_resultbulk_api_resultdict[str, Any]r   r   r   r   c                X    || _         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_resultr1   r   )r   rj   r   r   s      r   r   zBulkWriteResult.__init__   s+     "1&&&&&r   r   c                @    | j         j         d| j        d| j         dS r3   )r   r   rm   r   r   s    r   r   zBulkWriteResult.__repr__   s-    .)iiD,BiiUYUfiiiir   c                    | j         S )zThe raw bulk API result.)rm   r   s    r   rj   zBulkWriteResult.bulk_api_result   s     %%r   rP   c                    |                      d           t          t          | j                            d                    S )z!The number of documents inserted.inserted_count	nInsertedr"   r   rP   rm   rU   r   s    r   rq   zBulkWriteResult.inserted_count   :     	%%&6777C/33K@@AAAr   c                    |                      d           t          t          | j                            d                    S )z.The number of documents matched for an update.rR   nMatchedrs   r   s    r   rR   zBulkWriteResult.matched_count   9     	%%o666C/33J??@@@r   c                    |                      d           t          t          | j                            d                    S )rW   rX   rY   rs   r   s    r   rX   zBulkWriteResult.modified_count   rt   r   c                    |                      d           t          t          | j                            d                    S )re   rf   nRemovedrs   r   s    r   rf   zBulkWriteResult.deleted_count   rw   r   c                    |                      d           t          t          | j                            d                    S )z!The number of documents upserted.upserted_count	nUpsertedrs   r   s    r   r|   zBulkWriteResult.upserted_count   rt   r   Optional[dict[int, Any]]c                l    |                      d           | j        rd | j        d         D             S dS )z=A map of operation index to the _id of the upserted document.upserted_idsc                ,    i | ]}|d          |d         S )index_idr*   ).0upserts     r   
<dictcomp>z0BulkWriteResult.upserted_ids.<locals>.<dictcomp>   s"    bbbvF7OVE]bbbr   r[   N)r"   rm   rj   r   s    r   r   zBulkWriteResult.upserted_ids   sF     	%%n555! 	cbbAUV`Aabbbbtr   )rj   rk   r   r   r   r   r$   )r   rk   r\   )r   r~   )r   r%   r&   r'   r(   r   r   r)   rj   rq   rR   rX   rf   r|   r   r6   r7   s   @r   rh   rh      sT       77&I
' 
' 
' 
' 
' 
'j j j j & & & X& B B B XB
 A A A XA
 B B B XB
 A A A XA
 B B B XB
    X    r   rh   N)r'   
__future__r   typingr   r   r   r   pymongo.errorsr   r
   r,   r9   rB   r^   rh   r*   r   r   <module>r      s[      " " " " " " / / / / / / / / / / / / + + + + + +&# &# &# &# &# &# &# &#R" " " " "l " " "(# # # # #| # # #4+1 +1 +1 +1 +1< +1 +1 +1\- - - - -< - - -4= = = = =l = = = = =r   