
    =hQ                       d Z ddlmZ ddlmZmZmZmZmZm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZ ddlmZmZmZ ddlmZmZmZ dd	lmZmZmZ erdd
lmZ ddl m!Z! ee	ee"e
e"ee#e"ee"ef   f   f   f      ee"ef   f   Z$ee"e$f   Z% G d dee         Z& G d d      Z' G d d      Z( G d dee         Z) G d d      Z* G d de*      Z+ G d de*      Z, G d d      Z- G d d      Z.y)zOperation class definitions.    )annotations)TYPE_CHECKINGAnyGenericMappingOptionalSequenceTupleUnion)RawBSONDocument)helpers)validate_collation_or_none)validate_booleanvalidate_is_mappingvalidate_list)_gen_index_name_index_document_index_list)_CollationIn_DocumentType	_Pipeline)SON)_Bulkc                  <    e Zd ZdZdZd	dZd
dZddZddZddZ	y)	InsertOnez#Represents an insert_one operation._docc                    || _         y)zCreate an InsertOne instance.

        For use with :meth:`~pymongo.collection.Collection.bulk_write`.

        :Parameters:
          - `document`: The document to insert. If the document is missing an
            _id field one will be added.
        Nr   )selfdocuments     b/var/www/html/phonemate/phone_mate_backend/venv/lib/python3.12/site-packages/pymongo/operations.py__init__zInsertOne.__init__4   s     	    c                :    |j                  | j                         y)3Add this operation to the _Bulk instance `bulkobj`.N)
add_insertr   r   bulkobjs     r!   _add_to_bulkzInsertOne._add_to_bulk?   s    499%r#   c                "    d| j                   dS )Nz
InsertOne()r   r   s    r!   __repr__zInsertOne.__repr__C   s    DII=**r#   c                n    t        |      t        |       k(  r|j                  | j                  k(  S t        S N)typer   NotImplementedr   others     r!   __eq__zInsertOne.__eq__F   s+    ;$t*$::**r#   c                    | |k(   S r/    r2   s     r!   __ne__zInsertOne.__ne__K       5=  r#   N)r    r   returnNoner(   r   r9   r:   r9   strr3   r   r9   bool
__name__
__module____qualname____doc__	__slots__r"   r)   r-   r4   r7   r6   r#   r!   r   r   /   s#    -I	&+
!r#   r   c                  P    e Zd ZdZdZ	 	 d		 	 	 	 	 	 	 d
dZddZddZddZddZ	y)	DeleteOnez"Represents a delete_one operation._filter
_collation_hintNc                    |t        d|       |+t        |t              st        j                  |      | _        n|| _        || _        || _        y)a  Create a DeleteOne instance.

        For use with :meth:`~pymongo.collection.Collection.bulk_write`.

        :Parameters:
          - `filter`: A query that matches the document to delete.
          - `collation` (optional): An instance of
            :class:`~pymongo.collation.Collation`.
          - `hint` (optional): An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.4 and above.

        .. versionchanged:: 3.11
           Added the ``hint`` option.
        .. versionchanged:: 3.5
           Added the `collation` option.
        Nfilterr   
isinstancer=   r   r   rK   rI   rJ   r   rM   	collationhints       r!   r"   zDeleteOne.__init__T   K    4 &1JtS$9:A:Q:QRV:WDJDJ#r#   c                |    |j                  | j                  dt        | j                        | j                         y)r%      rQ   rR   N
add_deleterI   r   rJ   rK   r'   s     r!   r)   zDeleteOne._add_to_bulkw   2    LL0A	 	 	
r#   c                V    d| j                   d| j                  d| j                  dS )Nz
DeleteOne(, r+   rH   r,   s    r!   r-   zDeleteOne.__repr__   s,    DLL+2doo-@4::.PQRRr#   c                    t        |      t        |       k(  rG|j                  |j                  |j                  f| j                  | j                  | j                  fk(  S t        S r/   r0   rI   rJ   rK   r1   r2   s     r!   r4   zDeleteOne.__eq__   W    ;$t*$MM5#3#3U[[A

F  
 r#   c                    | |k(   S r/   r6   r2   s     r!   r7   zDeleteOne.__ne__   r8   r#   NNrM   Mapping[str, Any]rQ   Optional[_CollationIn]rR   Optional[_IndexKeyHint]r9   r:   r;   r<   r>   r@   r6   r#   r!   rG   rG   O   sS    ,2I
 -1(,	!$!!$ *!$ &	!$
 
!$F
S!r#   rG   c                  P    e Zd ZdZdZ	 	 d		 	 	 	 	 	 	 d
dZddZddZddZddZ	y)
DeleteManyz#Represents a delete_many operation.rH   Nc                    |t        d|       |+t        |t              st        j                  |      | _        n|| _        || _        || _        y)a!  Create a DeleteMany instance.

        For use with :meth:`~pymongo.collection.Collection.bulk_write`.

        :Parameters:
          - `filter`: A query that matches the documents to delete.
          - `collation` (optional): An instance of
            :class:`~pymongo.collation.Collation`.
          - `hint` (optional): An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.4 and above.

        .. versionchanged:: 3.11
           Added the ``hint`` option.
        .. versionchanged:: 3.5
           Added the `collation` option.
        NrM   rN   rP   s       r!   r"   zDeleteMany.__init__   rS   r#   c                |    |j                  | j                  dt        | j                        | j                         y)r%   r   rV   NrW   r'   s     r!   r)   zDeleteMany._add_to_bulk   rY   r#   c                V    d| j                   d| j                  d| j                  dS )NzDeleteMany(r[   r+   rH   r,   s    r!   r-   zDeleteMany.__repr__   s,    T\\,Bt.ADJJ>QRSSr#   c                    t        |      t        |       k(  rG|j                  |j                  |j                  f| j                  | j                  | j                  fk(  S t        S r/   r]   r2   s     r!   r4   zDeleteMany.__eq__   r^   r#   c                    | |k(   S r/   r6   r2   s     r!   r7   zDeleteMany.__ne__   r8   r#   r`   ra   r;   r<   r>   r@   r6   r#   r!   rf   rf      sS    -2I
 -1(,	!$!!$ *!$ &	!$
 
!$F
T!r#   rf   c                  Z    e Zd ZdZdZ	 	 	 d		 	 	 	 	 	 	 	 	 	 	 d
dZddZddZddZddZ	y)
ReplaceOnez#Represents a replace_one operation.)rI   r   _upsertrJ   rK   Nc                    |t        d|       |t        d|       |+t        |t              st	        j
                  |      | _        n|| _        || _        || _        || _	        || _
        y)a  Create a ReplaceOne instance.

        For use with :meth:`~pymongo.collection.Collection.bulk_write`.

        :Parameters:
          - `filter`: A query that matches the document to replace.
          - `replacement`: The new document.
          - `upsert` (optional): If ``True``, perform an insert if no documents
            match the filter.
          - `collation` (optional): An instance of
            :class:`~pymongo.collation.Collation`.
          - `hint` (optional): An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.2 and above.

        .. versionchanged:: 3.11
           Added the ``hint`` option.
        .. versionchanged:: 3.5
           Added the ``collation`` option.
        NrM   upsert)r   r   rO   r=   r   r   rK   rI   r   rn   rJ   )r   rM   replacementrp   rQ   rR   s         r!   r"   zReplaceOne.__init__   si    > &1Xv.JtS$9:A:Q:QRV:WDJDJ	#r#   c                    |j                  | j                  | j                  | j                  t	        | j
                        | j                         y)r%   rV   N)add_replacerI   r   rn   r   rJ   rK   r'   s     r!   r)   zReplaceOne._add_to_bulk  s=    LLIILL0A 	 	
r#   c                "   t        |      t        |       k(  rs|j                  |j                  |j                  |j                  |j
                  f| j                  | j                  | j                  | j                  |j
                  fk(  S t        S r/   )r0   rI   r   rn   rJ   rK   r1   r2   s     r!   r4   zReplaceOne.__eq__  st    ;$t*$MM5::u}}e>N>NPUP[P[]		b   r#   c                    | |k(   S r/   r6   r2   s     r!   r7   zReplaceOne.__ne__  r8   r#   c                    dj                  | j                  j                  | j                  | j                  | j
                  | j                  | j                        S )Nz {}({!r}, {!r}, {!r}, {!r}, {!r}))format	__class__rA   rI   r   rn   rJ   rK   r,   s    r!   r-   zReplaceOne.__repr__  sE    188NN##LLIILLOOJJ
 	
r#   )FNN)rM   rb   rq   z%Union[_DocumentType, RawBSONDocument]rp   r?   rQ   rc   rR   rd   r9   r:   r;   r>   r<   )
rA   rB   rC   rD   rE   r"   r)   r4   r7   r-   r6   r#   r!   rm   rm      si    -EI ,0(,*$!*$ ;*$ 	*$
 **$ &*$ 
*$X
	!
r#   rm   c                  D    e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 ddZddZd	dZy)
	_UpdateOpz)Private base class for update operations.)rI   r   rn   rJ   _array_filtersrK   c                   |t        d|       |t        d|       |t        d|       |+t        |t              st        j                  |      | _        n|| _        || _        || _	        || _
        || _        || _        y )NrM   rp   array_filters)r   r   r   rO   r=   r   r   rK   rI   r   rn   rJ   r{   )r   rM   docrp   rQ   r}   rR   s          r!   r"   z_UpdateOp.__init__*  s     &1Xv.$/=9JtS$9:A:Q:QRV:WDJDJ	#+r#   c                J   t        |t        |             r|j                  |j                  |j                  |j
                  |j                  |j                  f| j                  | j                  | j                  | j
                  | j                  | j                  fk(  S t        S r/   )	rO   r0   rI   r   rn   rJ   r{   rK   r1   r2   s     r!   r4   z_UpdateOp.__eq__D  s    eT$Z(

  $$ 		##

  r#   c           	         dj                  | j                  j                  | j                  | j                  | j
                  | j                  | j                  | j                        S )Nz&{}({!r}, {!r}, {!r}, {!r}, {!r}, {!r}))	rw   rx   rA   rI   r   rn   rJ   r{   rK   r,   s    r!   r-   z_UpdateOp.__repr__W  sN    7>>NN##LLIILLOOJJ
 	
r#   N)rM   rb   r~   #Union[Mapping[str, Any], _Pipeline]rp   r?   rQ   rc   r}   !Optional[list[Mapping[str, Any]]]rR   rd   )r3   objectr9   r?   r<   )rA   rB   rC   rD   rE   r"   r4   r-   r6   r#   r!   rz   rz   %  sS    3WI,!, 1, 	,
 *, 9, &,4&	
r#   rz   c                  T     e Zd ZdZdZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZddZ xZS )	UpdateOnez#Represents an update_one operation.r6   c                .    t         |   ||||||       y)a  Represents an update_one operation.

        For use with :meth:`~pymongo.collection.Collection.bulk_write`.

        :Parameters:
          - `filter`: A query that matches the document to update.
          - `update`: The modifications to apply.
          - `upsert` (optional): If ``True``, perform an insert if no documents
            match the filter.
          - `collation` (optional): An instance of
            :class:`~pymongo.collation.Collation`.
          - `array_filters` (optional): A list of filters specifying which
            array elements an update should apply.
          - `hint` (optional): An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.2 and above.

        .. versionchanged:: 3.11
           Added the `hint` option.
        .. versionchanged:: 3.9
           Added the ability to accept a pipeline as the `update`.
        .. versionchanged:: 3.6
           Added the `array_filters` option.
        .. versionchanged:: 3.5
           Added the `collation` option.
        Nsuperr"   r   rM   updaterp   rQ   r}   rR   rx   s          r!   r"   zUpdateOne.__init__h      L 	M4Pr#   c           	         |j                  | j                  | j                  d| j                  t	        | j
                        | j                  | j                         y)r%   FrQ   r}   rR   N
add_updaterI   r   rn   r   rJ   r{   rK   r'   s     r!   r)   zUpdateOne._add_to_bulk  sI    LLIILL0A-- 	 	
r#   FNNNrM   rb   r   r   rp   r?   rQ   rc   r}   r   rR   rd   r9   r:   r;   rA   rB   rC   rD   rE   r"   r)   __classcell__rx   s   @r!   r   r   c  sp    -I ,0;?(,&Q!&Q 4&Q 	&Q
 *&Q 9&Q &&Q 
&QP

r#   r   c                  T     e Zd ZdZdZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZddZ xZS )
UpdateManyz$Represents an update_many operation.r6   c                .    t         |   ||||||       y)a  Create an UpdateMany instance.

        For use with :meth:`~pymongo.collection.Collection.bulk_write`.

        :Parameters:
          - `filter`: A query that matches the documents to update.
          - `update`: The modifications to apply.
          - `upsert` (optional): If ``True``, perform an insert if no documents
            match the filter.
          - `collation` (optional): An instance of
            :class:`~pymongo.collation.Collation`.
          - `array_filters` (optional): A list of filters specifying which
            array elements an update should apply.
          - `hint` (optional): An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.2 and above.

        .. versionchanged:: 3.11
           Added the `hint` option.
        .. versionchanged:: 3.9
           Added the ability to accept a pipeline as the `update`.
        .. versionchanged:: 3.6
           Added the `array_filters` option.
        .. versionchanged:: 3.5
           Added the `collation` option.
        Nr   r   s          r!   r"   zUpdateMany.__init__  r   r#   c           	         |j                  | j                  | j                  d| j                  t	        | j
                        | j                  | j                         y)r%   Tr   Nr   r'   s     r!   r)   zUpdateMany._add_to_bulk  sI    LLIILL0A-- 	 	
r#   r   r   r;   r   r   s   @r!   r   r     sp    .I ,0;?(,&Q!&Q 4&Q 	&Q
 *&Q 9&Q &&Q 
&QP

r#   r   c                  .    e Zd ZdZdZddZedd       Zy)
IndexModelzRepresents an index to create.
__documentc                    t        |      }|j                  d      t        |      |d<   t        |      |d<   t	        |j                  dd            }|| _        ||| j                  d<   yy)a  Create an Index instance.

        For use with :meth:`~pymongo.collection.Collection.create_indexes`.

        Takes either a single key or a list containing (key, direction) pairs
        or keys.  If no direction is given, :data:`~pymongo.ASCENDING` will
        be assumed.
        The key(s) must be an instance of :class:`str`, and the direction(s) must
        be one of (:data:`~pymongo.ASCENDING`, :data:`~pymongo.DESCENDING`,
        :data:`~pymongo.GEO2D`, :data:`~pymongo.GEOSPHERE`,
        :data:`~pymongo.HASHED`, :data:`~pymongo.TEXT`).

        Valid options include, but are not limited to:

          - `name`: custom name to use for this index - if none is
            given, a name will be generated.
          - `unique`: if ``True``, creates a uniqueness constraint on the index.
          - `background`: if ``True``, this index should be created in the
            background.
          - `sparse`: if ``True``, omit from the index any documents that lack
            the indexed field.
          - `bucketSize`: for use with geoHaystack indexes.
            Number of documents to group together within a certain proximity
            to a given longitude and latitude.
          - `min`: minimum value for keys in a :data:`~pymongo.GEO2D`
            index.
          - `max`: maximum value for keys in a :data:`~pymongo.GEO2D`
            index.
          - `expireAfterSeconds`: <int> Used to create an expiring (TTL)
            collection. MongoDB will automatically delete documents from
            this collection after <int> seconds. The indexed field must
            be a UTC datetime or the data will not expire.
          - `partialFilterExpression`: A document that specifies a filter for
            a partial index.
          - `collation`: An instance of :class:`~pymongo.collation.Collation`
            that specifies the collation to use.
          - `wildcardProjection`: Allows users to include or exclude specific
            field paths from a `wildcard index`_ using the { "$**" : 1} key
            pattern. Requires MongoDB >= 4.2.
          - `hidden`: if ``True``, this index will be hidden from the query
            planner and will not be evaluated as part of query plan
            selection. Requires MongoDB >= 4.4.

        See the MongoDB documentation for a full list of supported options by
        server version.

        :Parameters:
          - `keys`: a single key or a list containing (key, direction) pairs
             or keys specifying the index to create.
          - `**kwargs` (optional): any additional index creation
            options (see the above list) should be passed as keyword
            arguments.

        .. versionchanged:: 3.11
           Added the ``hidden`` option.
        .. versionchanged:: 3.2
           Added the ``partialFilterExpression`` option to support partial
           indexes.

        .. _wildcard index: https://mongodb.com/docs/master/core/index-wildcard/
        nameNkeyrQ   )r   getr   r   r   pop_IndexModel__document)r   keyskwargsrQ   s       r!   r"   zIndexModel.__init__  so    | 4 ::f%,T2F6N'-u.vzz+t/LM	  +4DOOK( !r#   c                    | j                   S )zUAn index document suitable for passing to the createIndexes
        command.
        )r   r,   s    r!   r    zIndexModel.document#  s    
 r#   N)r   _IndexKeyHintr   r   r9   r:   )r9   zdict[str, Any]rA   rB   rC   rD   rE   r"   propertyr    r6   r#   r!   r   r     s%    (IE5N  r#   r   c                  0    e Zd ZdZdZdddZedd       Zy)	SearchIndexModelz$Represents a search index to create.r   Nc                P    |t        ||      | _        yt        |      | _        y)a  Create a Search Index instance.

        For use with :meth:`~pymongo.collection.Collection.create_search_index` and :meth:`~pymongo.collection.Collection.create_search_indexes`.

        :Parameters:
          - `definition` - The definition for this index.
          - `name` (optional) - The name for this index, if present.

        .. versionadded:: 4.5

        .. note:: Search indexes require a MongoDB server version 7.0+ Atlas cluster.
        N)r   
definition)r   )dict_SearchIndexModel__document)r   r   r   s      r!   r"   zSearchIndexModel.__init__0  s$     "DDO"j9DOr#   c                    | j                   S )zThe document for this index.)r   r,   s    r!   r    zSearchIndexModel.documentB  s     r#   r/   )r   rb   r   zOptional[str]r9   r:   )r9   rb   r   r6   r#   r!   r   r   +  s#    .I:$  r#   r   N)/rD   
__future__r   typingr   r   r   r   r   r	   r
   r   bson.raw_bsonr   pymongor   pymongo.collationr   pymongo.commonr   r   r   pymongo.helpersr   r   r   pymongo.typingsr   r   r   bson.sonr   pymongo.bulkr   r=   int
_IndexListr   r   rG   rf   rm   rz   r   r   r   r   r6   r#   r!   <module>r      s   # "	 	 	 *  8 O O I I B B" U3c5c7383D)D#EEFFGH'RUWZRZJ[[
 c:o&!& !@>! >!B>! >!BQ
' Q
h;
 ;
|7
	 7
t7
 7
tQ Qh r#   