
    i)iC3                       d Z ddlmZ ddlmZ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 G d de          Z G d de          ZdS )z{Result class definitions.

.. seealso:: This module is compatible with both the synchronous and asynchronous PyMongo APIs.
    )annotations)AnyMappingMutableMapping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     a/Users/user/workspace/sujinbaek/cqa-test-app/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.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 )InsertOneResultzThe return type for :meth:`~pymongo.collection.Collection.insert_one`
    and as part of :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.
    )__inserted_idinserted_idr   r   r   r   r   c                X    || _         t                                          |           d S r   )_InsertOneResult__inserted_idsuperr   )r   r3   r   r   s      r   r   zInsertOneResult.__init__J   s)    (&&&&&r   r   c                @    | j         j         d| j        d| j         dS Nr   z, acknowledged=r   )r   r   r5   r   r   s    r   r    zInsertOneResult.__repr__N   s.    ~&bb);bbdN_bbb	
r   c                    | j         S )zThe inserted document's _id.)r5   r   s    r   r3   zInsertOneResult.inserted_idS   s     !!r   )r3   r   r   r   r   r   r'   r   r   )
r   r*   r+   r,   r-   r   r    r.   r3   __classcell__r   s   @r   r1   r1   C   s          #I' ' ' ' ' '
 
 
 

 " " " X" " " " "r   r1   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_idsr6   r   )r   r@   r   r   s      r   r   zInsertManyResult.__init__^   s)    *&&&&&r   r   c                @    | j         j         d| j        d| j         dS r8   )r   r   rC   r   r   s    r   r    zInsertManyResult.__repr__b   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.
        )rC   r   s    r   r@   zInsertManyResult.inserted_idsg   s     ""r   )r@   rA   r   r   r   r   r'   )r   rA   )
r   r*   r+   r,   r-   r   r    r.   r@   r;   r<   s   @r   r>   r>   Y   s|        QQ#I' ' ' ' ' '
 
 
 

 # # # X# # # # #r   r>   c                       e Zd ZdZdZ	 d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 xZS )UpdateResulta  The return type for :meth:`~pymongo.collection.Collection.update_one`,
    :meth:`~pymongo.collection.Collection.update_many`, and
    :meth:`~pymongo.collection.Collection.replace_one`, and as part of
    :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.
    )__raw_result__in_client_bulkF
raw_resultOptional[Mapping[str, Any]]r   r   in_client_bulkc                f    || _         || _        t                                          |           d S r   )_UpdateResult__raw_result_UpdateResult__in_client_bulkr6   r   )r   rJ   r   rL   r   s       r   r   zUpdateResult.__init__   s3     ' .&&&&&r   r   r   c                @    | j         j         d| j        d| j         dS r8   )r   r   rN   r   r   s    r   r    zUpdateResult.__repr__   -    .)ddD,=ddPTPaddddr   c                    | j         S z/The raw result document returned by the server.rN   r   s    r   rJ   zUpdateResult.raw_result          r   intc                    |                      d           | j        J | j        s	| j        dS | j                            dd          S )z0The number of documents matched for this update.matched_countNr   n)r%   rN   rO   upserted_idgetr   s    r   rX   zUpdateResult.matched_count   sX     	%%o666 ,,,$ 	)9)E1 $$S!,,,r   c                    |                      d           | j        J t          t          | j                            d                    S )!The number of documents modified.modified_countN	nModified)r%   rN   r   rV   r[   r   s    r   r^   zUpdateResult.modified_count   sI     	%%&6777 ,,,C*..{;;<<<r   r   c                    |                      d           | j        J | j        r-| j                            d          r| j        d         d         S | j                            dd          S )z^The _id of the inserted document if an upsert took place. Otherwise
        ``None``.
        rZ   Nupserted_id)r%   rN   rO   r[   r   s    r   rZ   zUpdateResult.upserted_id   sv    
 	%%m444 ,,,  	8T%6%:%::%F%F 	8$Z077 $$Z666r   c                &    | j         J d| j         v S )zEWhether an upsert took place.

        .. versionadded:: 4.9
        Nra   rT   r   s    r   
did_upsertzUpdateResult.did_upsert   s!      ,,,T...r   )F)rJ   rK   r   r   rL   r   r'   )r   rK   r   rV   r:   r)   )r   r*   r+   r,   r-   r   r    r.   rJ   rX   r^   rZ   rd   r;   r<   s   @r   rG   rG   s   s        I  %	' ' ' ' ' ' 'e e e e ! ! ! X! - - - X- = = = X= 7 7 7 X7 / / / X/ / / / /r   rG   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`
    and as part of :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.
    )rH   rJ   Mapping[str, Any]r   r   r   r   c                X    || _         t                                          |           d S r   )_DeleteResult__raw_resultr6   r   )r   rJ   r   r   s      r   r   zDeleteResult.__init__   s)    &&&&&&r   r   c                @    | j         j         d| j        d| j         dS r8   )r   r   rj   r   r   s    r   r    zDeleteResult.__repr__   rQ   r   c                    | j         S rS   )rj   r   s    r   rJ   zDeleteResult.raw_result   rU   r   rV   c                b    |                      d           | j                            dd          S ) The number of documents deleted.deleted_countrY   r   )r%   rj   r[   r   s    r   ro   zDeleteResult.deleted_count   s1     	%%o666 $$S!,,,r   )rJ   rh   r   r   r   r   r'   )r   rh   re   )r   r*   r+   r,   r-   r   r    r.   rJ   ro   r;   r<   s   @r   rg   rg      s         
 "I' ' ' ' ' 'e e e e ! ! ! X! - - - X- - - - -r   rg   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 xZS )_BulkWriteResultBasez.Private base class for bulk write API results.)__bulk_api_resultbulk_api_resultdict[str, Any]r   r   r   r   c                X    || _         t                                          |           d S r   )%_BulkWriteResultBase__bulk_api_resultr6   r   r   rs   r   r   s      r   r   z_BulkWriteResultBase.__init__   s)    !0&&&&&r   r   c                @    | j         j         d| j        d| j         dS r8   )r   r   rv   r   r   s    r   r    z_BulkWriteResultBase.__repr__   s-    .)iiD,BiiUYUfiiiir   c                    | j         S )zThe raw bulk write API result.)rv   r   s    r   rs   z$_BulkWriteResultBase.bulk_api_result   s     %%r   rV   c                    |                      d           t          t          | j                            d                    S )z!The number of documents inserted.inserted_count	nInsertedr%   r   rV   rv   r[   r   s    r   r{   z#_BulkWriteResultBase.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.rX   nMatchedr}   r   s    r   rX   z"_BulkWriteResultBase.matched_count   s9     	%%o666C/33J??@@@r   c                    |                      d           t          t          | j                            d                    S )r]   r^   r_   r}   r   s    r   r^   z#_BulkWriteResultBase.modified_count   r~   r   c                    |                      d           d| j        v r-t          t          | j                            d                    S t          t          | j                            d                    S )rn   ro   nRemovednDeleted)r%   rv   r   rV   r[   r   s    r   ro   z"_BulkWriteResultBase.deleted_count   sh     	%%o666///T377
CCDDDT377
CCDDDr   c                    |                      d           t          t          | j                            d                    S )z!The number of documents upserted.upserted_count	nUpsertedr}   r   s    r   r   z#_BulkWriteResultBase.upserted_count   r~   r   rs   rt   r   r   r   r   r'   )r   rt   re   )r   r*   r+   r,   r-   r   r    r.   rs   r{   rX   r^   ro   r   r;   r<   s   @r   rq   rq      s8       88&I' ' ' ' ' 'j j j j & & & X& B B B XB
 A A A XA
 B B B XB
 E E E XE B B B XB B B B Br   rq   c                  H     e Zd ZdZdZd fd	ZddZedd            Z xZ	S )BulkWriteResultz>An object wrapper for collection-level bulk write API results.r/   rs   rt   r   r   r   r   c                L    t                                          ||           dS )a@  Create a BulkWriteResult instance.

        :param bulk_api_result: A result dict from the collection-level bulk write API
        :param acknowledged: Was this write result acknowledged? If ``False``
            then all properties of this object will raise
            :exc:`~pymongo.errors.InvalidOperation`.
        N)r6   r   rw   s      r   r   zBulkWriteResult.__init__	  s%     	,77777r   r   c                @    | j         j         d| j        d| j         dS r8   )r   r   rs   r   r   s    r   r    zBulkWriteResult.__repr__  s/    ~&dd)=ddPTPaddd	
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 )indexrb   r/   ).0upserts     r   
<dictcomp>z0BulkWriteResult.upserted_ids.<locals>.<dictcomp>  s"    bbbvF7OVE]bbbr   ra   N)r%   rs   r   s    r   r   zBulkWriteResult.upserted_ids  sF     	%%n555 	cbbAUV`Aabbbbtr   r   r'   )r   r   )
r   r*   r+   r,   r-   r   r    r.   r   r;   r<   s   @r   r   r     s|        HHI8 8 8 8 8 8
 
 
 

    X    r   r   c                       e Zd ZdZdZd fd
ZddZddZedd            Z	edd            Z
edd            Zedd            Z xZS )ClientBulkWriteResultz:An object wrapper for client-level bulk write API results.)__has_verbose_resultsrs   MutableMapping[str, Any]r   r   has_verbose_resultsr   r   c                Z    || _         t                                          ||           dS )aU  Create a ClientBulkWriteResult instance.

        :param bulk_api_result: A result dict from the client-level bulk write API
        :param acknowledged: Was this write result acknowledged? If ``False``
            then all properties of this object will raise
            :exc:`~pymongo.errors.InvalidOperation`.
        :param has_verbose_results: Should the returned result be verbose?
            If ``False``, then the ``insert_results``, ``update_results``, and
            ``delete_results`` properties of this object will raise
            :exc:`~pymongo.errors.InvalidOperation`.
        N)+_ClientBulkWriteResult__has_verbose_resultsr6   r   )r   rs   r   r   r   s       r   r   zClientBulkWriteResult.__init__&  s9    " &9"	
 	
 	
 	
 	
r   r   c                d    d                     | j        j        | j        | j        | j                  S )Nz%{}({!r}, acknowledged={}, verbose={}))formatr   r   rs   r   r   r   s    r   r    zClientBulkWriteResult.__repr__=  s4    6==N# $	
 
 	
r   r!   c                :    | j         st          d| d          dS )zARaise an exception on property access if verbose results are off.r#   zv is not available when the results are not set to be verbose. Check the verbose_results attribute to avoid this error.N)r   r	   r$   s     r   _raise_if_not_verbosez+ClientBulkWriteResult._raise_if_not_verboseE  sC    ) 	"A} A A A  	 	r   c                    | j         S )z/Whether the returned results should be verbose.)r   r   s    r   r   z)ClientBulkWriteResult.has_verbose_resultsN  s     ))r   Mapping[int, InsertOneResult]c                    |                      d           |                     d           t          t          t          t
          f         | j                            d                    S )z:A map of successful insertion operations to their results.insert_resultsinsertResults)r%   r   r   r   rV   r1   rs   r[   r   s    r   r   z$ClientBulkWriteResult.insert_resultsS  sa     	%%&6777""#3444C() $$_55
 
 	
r   Mapping[int, UpdateResult]c                    |                      d           |                     d           t          t          t          t
          f         | j                            d                    S )z7A map of successful update operations to their results.update_resultsupdateResults)r%   r   r   r   rV   rG   rs   r[   r   s    r   r   z$ClientBulkWriteResult.update_results]  a     	%%&6777""#3444C%& $$_55
 
 	
r   Mapping[int, DeleteResult]c                    |                      d           |                     d           t          t          t          t
          f         | j                            d                    S )z7A map of successful delete operations to their results.delete_resultsdeleteResults)r%   r   r   r   rV   rg   rs   r[   r   s    r   r   z$ClientBulkWriteResult.delete_resultsg  r   r   )rs   r   r   r   r   r   r   r   r'   r(   r)   )r   r   )r   r   )r   r   )r   r*   r+   r,   r-   r   r    r   r.   r   r   r   r   r;   r<   s   @r   r   r   !  s        DD*I
 
 
 
 
 
.
 
 
 
    * * * X* 
 
 
 X
 
 
 
 X
 
 
 
 X
 
 
 
 
r   r   N)r,   
__future__r   typingr   r   r   r   r   pymongo.errorsr	   r   r1   r>   rG   rg   rq   r   r   r/   r   r   <module>r      s    # " " " " " ? ? ? ? ? ? ? ? ? ? ? ? ? ? + + + + + +&# &# &# &# &# &# &# &#R" " " " "l " " ",# # # # #| # # #4@/ @/ @/ @/ @/< @/ @/ @/F- - - - -< - - -60B 0B 0B 0B 0B< 0B 0B 0Bf    *   :N
 N
 N
 N
 N
0 N
 N
 N
 N
 N
r   