
    &gS                      S r SSKJr  SSKrSSKJr  SSKJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJr  SSKJrJr  SSKJr  SSKJr  SS	K J!r!  SS
K"J#r#  SSK$J%r%J&r&J'r'J(r(J)r)  SSK*J+r+J,r,  SSK-J.r.  SSK/J0r0  SSK1J2r2J3r3  SSK4J5r5J6r6  SSK7J8r8  SSK9J:r:J;r;  SSK<J=r=J>r>J?r?J@r@  SSKAJBrB  SSKCJDrD  SSKEJFrFJGrGJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrP  SSKQJRrR  SSKSJTrTJUrU  SSKVJWrWJXrXJYrYJZrZJ[r[  SSK\J]r]J^r^J_r_J`r`  SSKaJbrbJcrcJdrd  Sre\" S5      rfSS0rg\\I\^   \G\F\J\^   \M\L4   rh " S  S!5      ri\(       a.  SSKjrjSS"K*Jkrk  SS#KlJmrm  SS$KnJoro  SS%KpJqrq  SS&KrJsrs  SS'K7Jtrt  SS(KQJuru   " S) S*\'R                  \\^   5      rwg)+z%Collection level utilities for Mongo.    )annotationsN)abc)TYPE_CHECKINGAnyAsyncContextManagerCallable	CoroutineGenericIterableIteratorMappingMutableMappingNoReturnOptionalSequenceTypeTypeVarUnioncastoverload)DEFAULT_CODEC_OPTIONSCodecOptions)ObjectId)RawBSONDocument)SON)	Timestamp)	ASCENDING_csotcommonhelpers_sharedmessage)_CollectionAggregationCommand _CollectionRawAggregationCommand)
_AsyncBulk)AsyncCollectionChangeStream)AsyncCommandCursorAsyncRawBatchCommandCursor)AsyncCursorAsyncRawBatchCursor)validate_collation_or_none)_ecoc_coll_name_esc_coll_name)ConfigurationErrorInvalidNameInvalidOperationOperationFailure)_check_write_command_response)_UNICODE_REPLACE_CODEC_OPTIONS)
DeleteMany	DeleteOne
IndexModel	InsertOne
ReplaceOneSearchIndexModel
UpdateMany	UpdateOne_IndexKeyHint
_IndexList_Op)DEFAULT_READ_CONCERN)ReadPreference_ServerMode)BulkWriteResultDeleteResultInsertManyResultInsertOneResultUpdateResult)_CollationIn_DocumentType_DocumentTypeArg	_Pipeline)DEFAULT_WRITE_CONCERNWriteConcernvalidate_booleanFTvalue   c                  "    \ rS rSrSrSr SrSrg)ReturnDocumentq   zAn enum used with
:meth:`~pymongo.asynchronous.collection.AsyncCollection.find_one_and_replace` and
:meth:`~pymongo.asynchronous.collection.AsyncCollection.find_one_and_update`.
FT N)__name__
__module____qualname____firstlineno____doc__BEFOREAFTER__static_attributes__rS       dC:\Suresh\moveshuttle\MDcreated\moveengine\venv\Lib\site-packages\pymongo/asynchronous/collection.pyrQ   rQ   q   s    
 F E;r\   rQ   )_AggregationCommand)AsyncClientSessionAsyncDatabase)AsyncConnection)Server)	Collation)ReadConcernc            	        ^  \ rS rSrSr      SK                   SLU 4S jjjrSMS jrSMS jrSNS jrSOS	 jr	SOS
 jr
SPS jrSQS jr\SNS j5       r\SNS j5       r\SRS j5       r\    SS         STS jj5       r\   SU         SVS jj5       r    SW         SXS jjr      SYS jrSrSQS jr\rSZS jr            S[                         S\S jjr      S]S jr          S^                         S_S jjr  S`             SaS jjr      SbS jr\R<                       Sc             SdS jj5       r Se               SfS jjr    Sg         ShS jjr!\R<                      Si           SjS jj5       r"              Sk                                   SlS jjr#             Sm                                 SnS  jjr$        So                     SpS! jjr%         Sq                       SrS" jjr&        So                     SsS# jjr'   Sg       StS$ jjr(         Su                         SvS% jjr)        Sw                     SxS& jjr*     Sy             SzS' jjr+     Sy             SzS( jjr, Se       S{S) jjr-S|S* jr.S}S+ jr/            S~S, jr0            SS- jr1SeSS. jjr2  S         SS/ jjr3        SS0 jr4  S         SS1 jjr5\R<                          SS2 j5       r6  S         SS3 jjr7  S       SS4 jjr8\R<                    S         SS5 jj5       r9\R<                    S         SS6 jj5       r:  S     SS7 jjr;  S     SS8 jjr<  S     SS9 jjr=   Sg         SS: jjr>  S         SS; jjr?  S         SS< jjr@  S         SS= jjrA  S         SS> jjrB  S           SS? jjrC  S     SS@ jjrD\R<                    S                 SSA jj5       rE   Sg           SSB jjrF  S         SSC jjrG\R<                    S         SSD jj5       rH    SW             SSE jjrIS\JR                  SSSS4                     SSF jjrL      S                 SSG jjrMSSS\JR                  SSSS4                       SSH jjrNSSS\JR                  SSSSS4	                         SSI jjrOSJrPU =rQ$ )AsyncCollection   z!An asynchronous Mongo collection.FNc	                ^  > [         TU ]  U=(       d    UR                  U=(       d    UR                  U=(       d    UR                  U=(       d    UR
                  5        [        U[        5      (       d  [        S[        U5       35      eSSK
Jn
  [        X5      (       dK  [        S [        U5      R                   5       5      (       d!  [        S[        U5      R                   35      eU(       a  SU;   a  [        S5      eSU;   a$  UR!                  S	5      (       d  [        S
U-  5      eUS   S:X  d	  US   S:X  a  [        SU-  5      eSU;   a  [        S5      eXl        X l        U R"                  R&                   SU R$                   3U l        U R                  R+                  S[,        S9U l        UR0                  R2                  R4                  U l        U(       d  U	(       aB  [8        (       a,  [:        R<                  " S[>        SS9  U RA                  X5        g[C        S5      eg)a^  Get / create an asynchronous Mongo collection.

Raises :class:`TypeError` if `name` is not an instance of
:class:`str`. Raises :class:`~pymongo.errors.InvalidName` if `name` is
not a valid collection name. Any additional keyword arguments will be used
as options passed to the create command. See
:meth:`~pymongo.asynchronous.database.AsyncDatabase.create_collection` for valid
options.

If `create` is ``True``, `collation` is specified, or any additional
keyword arguments are present, a ``create`` command will be
sent, using ``session`` if specified. Otherwise, a ``create`` command
will not be sent and the collection will be created implicitly on first
use. The optional ``session`` argument is *only* used for the ``create``
command, it is not associated with the collection afterward.

:param database: the database to get a collection from
:param name: the name of the collection to get
:param create: **Not supported by AsyncCollection**.
:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions`. If ``None`` (the
    default) database.codec_options is used.
:param read_preference: The read preference to use. If
    ``None`` (the default) database.read_preference is used.
:param write_concern: An instance of
    :class:`~pymongo.write_concern.WriteConcern`. If ``None`` (the
    default) database.write_concern is used.
:param read_concern: An instance of
    :class:`~pymongo.read_concern.ReadConcern`. If ``None`` (the
    default) database.read_concern is used.
:param collation: An instance of
    :class:`~pymongo.collation.Collation`. If a collation is provided,
    it will be passed to the create collection command.
:param session: **Not supported by AsyncCollection**.
:param kwargs: **Not supported by AsyncCollection**.

.. versionchanged:: 4.2
   Added the ``clusteredIndex`` and ``encryptedFields`` parameters.

.. versionchanged:: 4.0
   Removed the reindex, map_reduce, inline_map_reduce,
   parallel_scan, initialize_unordered_bulk_op,
   initialize_ordered_bulk_op, group, count, insert, save,
   update, remove, find_and_modify, and ensure_index methods. See the
   :ref:`pymongo4-migration-guide`.

.. versionchanged:: 3.6
   Added ``session`` parameter.

.. versionchanged:: 3.4
   Support the `collation` option.

.. versionchanged:: 3.2
   Added the read_concern option.

.. versionchanged:: 3.0
   Added the codec_options, read_preference, and write_concern options.
   Removed the uuid_subtype attribute.
   :class:`~pymongo.asynchronous.collection.AsyncCollection` no longer returns an
   instance of :class:`~pymongo.asynchronous.collection.AsyncCollection` for attribute
   names with leading underscores. You must use dict-style lookups
   instead::

       collection['__my_collection__']

   Not:

       collection.__my_collection__

.. seealso:: The MongoDB documentation on `collections <https://dochub.mongodb.org/core/collections>`_.
z%name must be an instance of str, not r   r`   c              3  >   #    U  H  oR                   S :H  v   M     g7f)ra   N)rT   ).0clss     r]   	<genexpr>+AsyncCollection.__init__.<locals>.<genexpr>   s     YBX3||6BXs   z!AsyncDatabase required but given .. collection names cannot be empty$)oplog.$mainz$cmdz)collection names must not contain '$': %r.z3collection names must not start or end with '.': %r z4collection names must not contain the null characterreplace)unicode_decode_error_handlerdocument_classzhThe `create` and `kwargs` arguments to AsyncCollection are deprecated and will be removed in PyMongo 5.0   )
stacklevelzDAsyncCollection does not support the `create` or `kwargs` arguments.N)"super__init__codec_optionsread_preferencewrite_concernread_concern
isinstancestr	TypeErrortypepymongo.asynchronous.databasera   any__mro__rT   r.   
startswith	_database_namename
_full_name_replacedict_write_response_codec_optionsclientoptionstimeout_timeout_IS_SYNCwarningswarnDeprecationWarning_create
ValueError)selfdatabaser   creater}   r~   r   r   sessionkwargsra   	__class__s              r]   r|   AsyncCollection.__init__   s   f 	3X337x773X331H11		
 $$$CDJ<PQQ?(22Y$x.BXBXYYY"CDND[D[C\ ]^^tt|@AA$;0G H HIDPQQ7c>T"X_SVZZ[[T>TUU7?
!^^0014::,?-1-?-?-H-H)24 .I .
* !//77Vx~& 
 V- Z  r\   c           
         UR                  S5      (       a<  U R                   SU 3n[        [        U 5      R                   SU< SU SU S35      eU R                  U5      $ )zGet a sub-collection of this collection by name.

Raises InvalidName if an invalid collection name is used.

:param name: the name of the collection to get
_rs   z has no attribute z. To access the z collection, use database['z'].)r   r   AttributeErrorr   rT   __getitem__)r   r   	full_names      r]   __getattr__AsyncCollection.__getattr__  su     ??3::,av.I :&&''9$AQR[Q\-i[=  %%r\   c           	         [        U R                  U R                   SU 3SU R                  U R                  U R
                  U R                  5      $ )Nrs   Frg   r   r   r}   r~   r   r   )r   r   s     r]   r   AsyncCollection.__getitem__  sO    NNzzl!D6"  
 	
r\   c                j    [        U 5      R                   SU R                  < SU R                  < S3$ )N(z, ))r   rT   r   r   r   s    r]   __repr__AsyncCollection.__repr__'  s/    t*%%&a'9DJJ>KKr\   c                    [        U[        5      (       a9  U R                  UR                  :H  =(       a    U R                  UR
                  :H  $ [        $ N)r   rg   r   r   r   r   NotImplementedr   others     r]   __eq__AsyncCollection.__eq__*  s:    e_-->>U^^3P

ejj8PPr\   c                    X:X  + $ r   rS   r   s     r]   __ne__AsyncCollection.__ne__/  s      r\   c                D    [        U R                  U R                  45      $ r   )hashr   r   r   s    r]   __hash__AsyncCollection.__hash__2  s    T^^TZZ011r\   c                D    [        [        U 5      R                   S35      e)Nzq objects do not implement truth value testing or bool(). Please compare with None instead: collection is not None)NotImplementedErrorr   rT   r   s    r]   __bool__AsyncCollection.__bool__5  s)    !Dz""# $8 8
 	
r\   c                    U R                   $ )zoThe full name of this :class:`AsyncCollection`.

The full name is of the form `database_name.collection_name`.
)r   r   s    r]   r   AsyncCollection.full_name<  s     r\   c                    U R                   $ )z*The name of this :class:`AsyncCollection`.)r   r   s    r]   r   AsyncCollection.nameD  s     zzr\   c                    U R                   $ )zkThe :class:`~pymongo.asynchronous.database.AsyncDatabase` that this
:class:`AsyncCollection` is a part of.
)r   r   s    r]   r   AsyncCollection.databaseI  s    
 ~~r\   c                    g r   rS   r   r}   r~   r   r   s        r]   with_optionsAsyncCollection.with_optionsP       	r\   c                    g r   rS   r   s        r]   r   r   Z  r   r\   c           
         [        U R                  U R                  SU=(       d    U R                  U=(       d    U R                  U=(       d    U R
                  U=(       d    U R                  5      $ )a?  Get a clone of this collection changing the specified settings.

  >>> coll1.read_preference
  Primary()
  >>> from pymongo import ReadPreference
  >>> coll2 = coll1.with_options(read_preference=ReadPreference.SECONDARY)
  >>> coll1.read_preference
  Primary()
  >>> coll2.read_preference
  Secondary(tag_sets=None)

:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions`. If ``None`` (the
    default) the :attr:`codec_options` of this :class:`AsyncCollection`
    is used.
:param read_preference: The read preference to use. If
    ``None`` (the default) the :attr:`read_preference` of this
    :class:`AsyncCollection` is used. See :mod:`~pymongo.read_preferences`
    for options.
:param write_concern: An instance of
    :class:`~pymongo.write_concern.WriteConcern`. If ``None`` (the
    default) the :attr:`write_concern` of this :class:`AsyncCollection`
    is used.
:param read_concern: An instance of
    :class:`~pymongo.read_concern.ReadConcern`. If ``None`` (the
    default) the :attr:`read_concern` of this :class:`AsyncCollection`
    is used.
Fr   r   s        r]   r   r   d  s[    F NNJJ/T//3t33/T//-D--
 	
r\   c                b    UR                  S5      nUb  [        S0 UD6$ U R                  U5      $ )NwriteConcernrS   )getrK   _write_concern_for)r   cmdr   raw_wcs       r]   _write_concern_for_cmd&AsyncCollection._write_concern_for_cmd  s7     ()&))**733r\   c                    [        S5      e)Nz('AsyncCollection' object is not iterable)r   r   s    r]   __next__AsyncCollection.__next__  s    BCCr\   c                .   SU R                   ;  a/  [        S[        U 5      R                   S3U R                   -  5      e[        S[        U 5      R                   S[        U 5      R                   S3U R                   R	                  S5      S   -  5      e)zAThis is only here so that some API misusages are easier to debug.rs   'z' object is not callable. If you meant to call the '%s' method on an 'AsyncDatabase' object it is failing because no such method exists.zE' object is not callable. If you meant to call the '%s' method on a 'z5' object it is failing because no such method exists.rt   )r   r   r   rT   splitr   argsr   s      r]   __call__AsyncCollection.__call__  s    djj DJ''( )  !JJ'  T
##$ %**.t**=*=)> ?557;zz7G7G7LR7PQ
 	
r\   c                p   #    [        U UUUUUUUUU	U
UU5      nUR                  5       I Sh  vN   U$  N7f)a  Watch changes on this collection.

Performs an aggregation with an implicit initial ``$changeStream``
stage and returns a
:class:`~pymongo.asynchronous.change_stream.AsyncCollectionChangeStream` cursor which
iterates over changes on this collection.

.. code-block:: python

   async with await db.collection.watch() as stream:
       async for change in stream:
           print(change)

The :class:`~pymongo.asynchronous.change_stream.AsyncCollectionChangeStream` iterable
blocks until the next change document is returned or an error is
raised. If the
:meth:`~pymongo.asynchronous.change_stream.AsyncCollectionChangeStream.next` method
encounters a network error when retrieving a batch from the server,
it will automatically attempt to recreate the cursor such that no
change events are missed. Any error encountered during the resume
attempt indicates there may be an outage and will be raised.

.. code-block:: python

    try:
        async with await db.coll.watch([{"$match": {"operationType": "insert"}}]) as stream:
            async for insert_change in stream:
                print(insert_change)
    except pymongo.errors.PyMongoError:
        # The AsyncChangeStream encountered an unrecoverable error or the
        # resume attempt failed to recreate the cursor.
        logging.error("...")

For a precise description of the resume process see the
`change streams specification`_.

.. note:: Using this helper method is preferred to directly calling
    :meth:`~pymongo.asynchronous.collection.AsyncCollection.aggregate` with a
    ``$changeStream`` stage, for the purpose of supporting
    resumability.

.. warning:: This AsyncCollection's :attr:`read_concern` must be
    ``ReadConcern("majority")`` in order to use the ``$changeStream``
    stage.

:param pipeline: A list of aggregation pipeline stages to
    append to an initial ``$changeStream`` stage. Not all
    pipeline stages are valid after a ``$changeStream`` stage, see the
    MongoDB documentation on change streams for the supported stages.
:param full_document: The fullDocument to pass as an option
    to the ``$changeStream`` stage. Allowed values: 'updateLookup',
    'whenAvailable', 'required'. When set to 'updateLookup', the
    change notification for partial updates will include both a delta
    describing the changes to the document, as well as a copy of the
    entire document that was changed from some time after the change
    occurred.
:param full_document_before_change: Allowed values: 'whenAvailable'
    and 'required'. Change events may now result in a
    'fullDocumentBeforeChange' response field.
:param resume_after: A resume token. If provided, the
    change stream will start returning changes that occur directly
    after the operation specified in the resume token. A resume token
    is the _id value of a change document.
:param max_await_time_ms: The maximum time in milliseconds
    for the server to wait for changes before responding to a getMore
    operation.
:param batch_size: The maximum number of documents to return
    per batch.
:param collation: The :class:`~pymongo.collation.Collation`
    to use for the aggregation.
:param start_at_operation_time: If provided, the resulting
    change stream will only return changes that occurred at or after
    the specified :class:`~bson.timestamp.Timestamp`. Requires
    MongoDB >= 4.0.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param start_after: The same as `resume_after` except that
    `start_after` can resume notifications after an invalidate event.
    This option and `resume_after` are mutually exclusive.
:param comment: A user-provided comment to attach to this
    command.
:param show_expanded_events: Include expanded events such as DDL events like `dropIndexes`.

:return: A :class:`~pymongo.asynchronous.change_stream.AsyncCollectionChangeStream` cursor.

.. versionchanged:: 4.3
   Added `show_expanded_events` parameter.

.. versionchanged:: 4.2
   Added ``full_document_before_change`` parameter.

.. versionchanged:: 4.1
   Added ``comment`` parameter.

.. versionchanged:: 3.9
   Added the ``start_after`` parameter.

.. versionchanged:: 3.7
   Added the ``start_at_operation_time`` parameter.

.. versionadded:: 3.6

.. seealso:: The MongoDB documentation on `changeStreams <https://mongodb.com/docs/manual/changeStreams/>`_.

.. _change streams specification:
    https://github.com/mongodb/specifications/blob/master/source/change-streams/change-streams.md
N)r%   _initialize_cursor)r   pipelinefull_documentresume_aftermax_await_time_ms
batch_size	collationstart_at_operation_timer   start_aftercommentfull_document_before_changeshow_expanded_eventschange_streams                 r]   watchAsyncCollection.watch  sX     t 4#' 
  ..000 	1s   +646c                h   #    U R                   R                  R                  X5      I S h  vN $  N7fr   )r   r   _conn_for_writes)r   r   	operations      r]   r    AsyncCollection._conn_for_writes>  s(      ^^**;;GOOOOs   )202c                  #    U R                   R                  R                  U
5       ISh  vN nUR                  U R                   R                  UU=(       d    U R                  U
5      U=(       d    U R                  UUUUSU	UU R                   R                  UUS9I Sh  vN sSSS5      ISh  vN   $  N N N	! , ISh  vN  (       d  f       g= f7f)a  Internal command helper.

:param conn` - A AsyncConnection instance.
:param command` - The command itself, as a :class:`~bson.son.SON` instance.
:param read_preference` (optional) - The read preference to use.
:param codec_options` (optional) - An instance of
    :class:`~bson.codec_options.CodecOptions`.
:param check: raise OperationFailure if there are errors
:param allowable_errors: errors to ignore if `check` is True
:param read_concern` (optional) - An instance of
    :class:`~pymongo.read_concern.ReadConcern`.
:param write_concern: An instance of
    :class:`~pymongo.write_concern.WriteConcern`.
:param collation` (optional) - An instance of
    :class:`~pymongo.collation.Collation`.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param retryable_write: True if this command is a retryable
    write.
:param user_fields: Response fields that should be decoded
    using the TypeDecoders from codec_options, passed to
    bson._decode_all_selective.

:return: The result document.
NT)r   r   parse_write_concern_errorr   r   r   retryable_writeuser_fields)r   r   _tmp_sessioncommandr   _read_preference_forr}   )r   connr   r~   r}   checkallowable_errorsr   r   r   r   r   r   ss                 r]   _commandAsyncCollection._commandC  s     P >>((55g>>!##E4#<#<W#E3!3!3 )+*.#~~,, /' &   ?>> ?>>>sW   *CB9CA3B?#B;$B?'C3B=4C;B?=C?CCCCc           
       #    SU0nU(       a  XWS'   U(       a(  SU;   a  [        US   5      US'   UR                  U5        U R                  U[        R                  S9I Sh  vN  ISh  vN nU(       a)  UR
                  S:  a  [        SUR
                   S35      eU R                  UU[        R                  U R                  U5      UUS	9I Sh  vN   SSS5      ISh  vN   g N N N N! , ISh  vN  (       d  f       g= f7f)
z.Sends a create command with the given options.r   encryptedFieldssizer   N   zDriver support of Queryable Encryption is incompatible with server. Upgrade server to use Queryable Encryption. Got maxWireVersion z. but need maxWireVersion >= 21 (MongoDB >=7.0))r~   r   r   r   )floatupdater   r=   CREATEmax_wire_versionr-   r  r?   PRIMARYr   )	r   r   r   r   r   encrypted_fieldsqev2_requiredr   r   s	            r]   _create_helperAsyncCollection._create_helper}  s       (.%5!" "'"8JJw..w#**.MMMMQU!6!6!;(**.*?*?)@@np  -- . 6 6"55g>#      NMM NMMMsm   A D"C*#D+C,,D/A%C2C.C2D$C0%D,D.C20D2D	8C;9D	Dc                V  #    [        UR                  SS 5      5      nUR                  SS 5      nU(       a  [        R                  " SU5        SSS0SS.0nU R	                  [        X@R                  5      US USS	9I S h  vN   U R	                  [        X@R                  5      US U5      I S h  vN   U R	                  U R                  XX$S
9I S h  vN   U R                  S[        4/U5      I S h  vN   g U R	                  U R                  XU5      I S h  vN   g  N Nq NP N1 N7f)Nr   r  r  clusteredIndex_idrO   T)keyunique)r  )r  __safeContent__)
r*   popr   validate_is_mappingr  r,   r   r+   create_indexr   )r   r   r   r   r  optss         r]   r   AsyncCollection._create  s8    
 /w{{;/MN	";;'8$?&&'9;KL$uajD&IJD%%/<" &    %% 0**=tT7   %%

G &    ##&7%C$DgNNN%%djj'gNNN ONsZ   A>D) D.D)/D!0"D)D# D)3D%4%D)D'D)!D)#D)%D)'D)c                l  #    [         R                  " SU5        [        XX5US9nU H  n UR                  U5        M     U R                  U5      n	UR                  X[        R                  5      I Sh  vN n
U
b  [        U
S5      $ [        0 S5      $ ! [         a    [        U< S35      Sef = f N=7f)a!
  Send a batch of write operations to the server.

Requests are passed as a list of write operation instances (
:class:`~pymongo.operations.InsertOne`,
:class:`~pymongo.operations.UpdateOne`,
:class:`~pymongo.operations.UpdateMany`,
:class:`~pymongo.operations.ReplaceOne`,
:class:`~pymongo.operations.DeleteOne`, or
:class:`~pymongo.operations.DeleteMany`).

  >>> async for doc in db.test.find({}):
  ...     print(doc)
  ...
  {'x': 1, '_id': ObjectId('54f62e60fba5226811f634ef')}
  {'x': 1, '_id': ObjectId('54f62e60fba5226811f634f0')}
  >>> # DeleteMany, UpdateOne, and UpdateMany are also available.
  ...
  >>> from pymongo import InsertOne, DeleteOne, ReplaceOne
  >>> requests = [InsertOne({'y': 1}), DeleteOne({'x': 1}),
  ...             ReplaceOne({'w': 1}, {'z': 1}, upsert=True)]
  >>> result = await db.test.bulk_write(requests)
  >>> result.inserted_count
  1
  >>> result.deleted_count
  1
  >>> result.modified_count
  0
  >>> result.upserted_ids
  {2: ObjectId('54f62ee28891e756a6e1abd5')}
  >>> async for doc in db.test.find({}):
  ...     print(doc)
  ...
  {'x': 1, '_id': ObjectId('54f62e60fba5226811f634f0')}
  {'y': 1, '_id': ObjectId('54f62ee2fba5226811f634f1')}
  {'z': 1, '_id': ObjectId('54f62ee28891e756a6e1abd5')}

:param requests: A list of write operations (see examples above).
:param ordered: If ``True`` (the default) requests will be
    performed on the server serially, in the order provided. If an error
    occurs all remaining operations are aborted. If ``False`` requests
    will be performed on the server in arbitrary order, possibly in
    parallel, and all operations will be attempted.
:param bypass_document_validation: (optional) If ``True``, allows the
    write to opt-out of document level validation. Default is
    ``False``.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param let: Map of parameter names and values. Values must be
    constant or closed expressions that do not reference document
    fields. Parameters can then be accessed as variables in an
    aggregate expression context (e.g. "$$var").

:return: An instance of :class:`~pymongo.results.BulkWriteResult`.

.. seealso:: :ref:`writes-and-ids`

.. note:: `bypass_document_validation` requires server version
  **>= 3.2**

.. versionchanged:: 4.1
   Added ``comment`` parameter.
   Added ``let`` parameter.

.. versionchanged:: 3.6
   Added ``session`` parameter.

.. versionchanged:: 3.2
  Added bypass_document_validation support

.. versionadded:: 3.0
requests)r   letz is not a valid requestNTF)r   validate_listr$   _add_to_bulkr   r   r   executer=   INSERTrA   )r   r  orderedbypass_document_validationr   r   r  blkrequestr   bulk_api_results              r]   
bulk_writeAsyncCollection.bulk_write  s     f 	Z2(BY\]GQ$$S)   //8 #MCJJ OO&"?D99r5)) " Q7+-D EFDPQ Ps'   (B4B8B44B25B4B//B4c                r  ^ ^^^
#    T=(       d    T R                   mTR                  nT R                  X!/S.m
Ub  UT
S'           SUU
U U4S jjn	T R                  R                  R                  XU[        R                  S9I Sh  vN   [        U[        5      (       d  UR                  S5      $ g N+7f)z0Internal helper for inserting a single document.)insertr#  	documentsNr   c           
        >#    Tb  TTS'   UR                  TR                  R                  TTTR                  U TR                  R                  US9I S h  vN n[        U5        g  N7f)NbypassDocumentValidationr   r}   r   r   r   )r   r   r   r   r   r1   )r   r   r   resultbypass_doc_valr   r   r   s       r]   _insert_command4AsyncCollection._insert_one.<locals>._insert_command.  so      )6D23<<##+"@@~~,, / (  F *&1s   AA)A'A)r  r  )r   Optional[AsyncClientSession]r   rb   r   boolreturnNone)r   acknowledgedr   r   r   _retryable_writer=   r"  r   r   r   )r   docr#  r   op_idr1  r   r   r8  r2  r   s   `  ` `    @r]   _insert_oneAsyncCollection._insert_one  s      &;););$11!YY7O!(GI	21	29H	2[_	2	2 	2$ nn##447cjj 5 
 	
 	
 #//775>!	
s   BB7	B5
,B7c                  #    [         R                  " SU5        [        U[        5      (       d  SU;   d  [	        5       US'   U R                  U5      n[        U R                  USUSUUUS9I Sh  vN UR                  5      $  N7f)ar  Insert a single document.

  >>> await db.test.count_documents({'x': 1})
  0
  >>> result = await db.test.insert_one({'x': 1})
  >>> result.inserted_id
  ObjectId('54f112defba522406c9cc208')
  >>> await db.test.find_one({'x': 1})
  {'x': 1, '_id': ObjectId('54f112defba522406c9cc208')}

:param document: The document to insert. Must be a mutable mapping
    type. If the document does not have an _id field one will be
    added automatically.
:param bypass_document_validation: (optional) If ``True``, allows the
    write to opt-out of document level validation. Default is
    ``False``.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.

:return: - An instance of :class:`~pymongo.results.InsertOneResult`.

.. seealso:: :ref:`writes-and-ids`

.. note:: `bypass_document_validation` requires server version
  **>= 3.2**

.. versionchanged:: 4.1
   Added ``comment`` parameter.

.. versionchanged:: 3.6
   Added ``session`` parameter.

.. versionchanged:: 3.2
  Added bypass_document_validation support

.. versionadded:: 3.0
documentr  TN)r#  r   r;  r1  r   r   )	r   validate_is_document_typer   r   r   r   rD   r<  r8  )r   r?  r$  r   r   r   s         r]   
insert_oneAsyncCollection.insert_oneH  s     \ 	((X>8_55(9J&jHUO//8""+9 #   &&
 	
s   A.B0B1Bc                  ^^	#    [        T[        R                  5      (       a&  [        T[        R                  5      (       d  T(       d  [	        S5      e/ m	SUU	4S jjnU R                  U5      n[        XX5S9n[        U" 5       5      Ul        UR                  Xt[        R                  5      I Sh  vN   [        T	UR                  5      $  N7f)ab  Insert an iterable of documents.

  >>> await db.test.count_documents({})
  0
  >>> result = await db.test.insert_many([{'x': i} for i in range(2)])
  >>> await result.inserted_ids
  [ObjectId('54f113fffba522406c9cc20e'), ObjectId('54f113fffba522406c9cc20f')]
  >>> await db.test.count_documents({})
  2

:param documents: A iterable of documents to insert.
:param ordered: If ``True`` (the default) documents will be
    inserted on the server serially, in the order provided. If an error
    occurs all remaining inserts are aborted. If ``False``, documents
    will be inserted on the server in arbitrary order, possibly in
    parallel, and all document inserts will be attempted.
:param bypass_document_validation: (optional) If ``True``, allows the
    write to opt-out of document level validation. Default is
    ``False``.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.

:return: An instance of :class:`~pymongo.results.InsertManyResult`.

.. seealso:: :ref:`writes-and-ids`

.. note:: `bypass_document_validation` requires server version
  **>= 3.2**

.. versionchanged:: 4.1
   Added ``comment`` parameter.

.. versionchanged:: 3.6
   Added ``session`` parameter.

.. versionchanged:: 3.2
  Added bypass_document_validation support

.. versionadded:: 3.0
z"documents must be a non-empty listc               3     >#    T Hj  n [         R                  " SU 5        [        U [        5      (       d'  SU ;  a  [	        5       U S'   TR                  U S   5        [        R                  U 4v   Ml     g7f)z6A generator that validates documents and handles _ids.r?  r  N)r   r@  r   r   r   appendr!   _INSERT)r?  r,  inserted_idss    r]   gen(AsyncCollection.insert_many.<locals>.gen  sa     %00XF!(O<<H,*2* ''811 &s   A2A5)r   N)r6  z'Iterator[tuple[int, Mapping[str, Any]]])r   r   r   r   r   r   r$   listopsr!  r=   r"  rC   r8  )
r   r,  r#  r$  r   r   rH  r   r%  rG  s
    `       @r]   insert_manyAsyncCollection.insert_many  s     h 9cll33)S[[11@AA')	2 	2 //8(BTsu+kk-#**===m.H.HII 	>s   B/C3C4Cc           
       #    [        SU5        [        U
5      n
U=(       d    U R                  nUR                  nUUUUS.nU
b  U(       d  [	        S5      eU
US'   Ub  U(       d  [	        S5      eUUS'   UbR  U(       d  UR
                  S:  a  [	        S	5      e[        U[        5      (       d  [        R                  " U5      nUUS
'   Ub>  U(       d  UR
                  S:  a  [	        S5      e[        R                  " SU5        UUS'   U R                  UU/S.nUb  [        R                  " SU5        UUS'   Ub  UUS'   U	b  U	US'   UR                  U R                  R                  UUU R                  UU R                  R                   US9I Sh  vN R#                  5       n[%        U5        UR'                  S5      (       a  SU;  a  SUS'   OSUS'   SU;   a  US   S   S   US'   U(       d  gU$  Nb7f)!Internal update / replace helper.upsert)qumultirP  N3Collation is unsupported for unacknowledged writes.r   6arrayFilters is unsupported for unacknowledged writes.arrayFilters   zPMust be connected to MongoDB 4.2+ to use hint on unacknowledged update commands.hint   zPMust be connected to MongoDB 8.0+ to use sort on unacknowledged update commands.sort)r	  r#  updatesr  r   r.  r/  nupsertedTupdatedExistingFr   r  )rL   r*   r   r8  r-   r  r   r   r    _index_documentr   r  r   r   r   r   r   copyr1   r   )r   r   criteriar?  rP  rS  r   r;  r#  r1  r   array_filtersrX  r   r   r  rZ  r   r8  
update_docr   r0  s                         r]   _updateAsyncCollection._update  s'    * 	6*.y9	%;););$11	&

  ()^__*3
;'$()abb-:
>*D$9$9A$=(f  dC((%55d;!%JvD$9$9B$>(f  &&vt4!%Jv!YY7
|T?&&uc2 GEN!(GI%2@G./
 ,,##+"@@~~,, /    $& 	 	&f-::c??z7(,F$%(-F$% V#%+J%7%:5%Az"/s   FG;G9A#G;c                  ^ ^^^^^^^^	^
^^^^^#            SUU	U
UUUUUUUUU UUU4S jjnT R                   R                  R                  T=(       d    T R                  R                  =(       a    T(       + UUU5      I Sh  vN $  N7f)rO  c                ^   >#    TR                  UTTTTTTTTTTT	U UT
TTS9I S h  vN $  N7f)N)rP  rS  r   r;  r#  r1  r   rb  rX  r   r   r  rZ  r   )rd  )r   r   r   rb  r1  r   r   ra  r?  rX  r  rS  r;  r#  r   rZ  rP  r   s      r]   rd  2AsyncCollection._update_retryable.<locals>._updateH  s[      +-#+ /# &    s   #-+-N)r   r4  r   rb   r   r5  r6  Optional[Mapping[str, Any]])r   r   r9  r   r8  )r   ra  r?  r   rP  rS  r   r;  r#  r1  r   rb  rX  r   r  rZ  r   rd  s   ``` ````````` ``` r]   _update_retryable!AsyncCollection._update_retryable3  s     *	1	9H	[_	(	 	 	. ^^**;;0d00>>Lu9	
 
 	
 
s   A5BBBc                F  #    [         R                  " SU5        [         R                  " U5        Ub  [         R                  " SU5        U R                  U5      n[	        U R                  UU[        R                  UUUUUUUU	U
S9I Sh  vN UR                  5      $  N7f)a5
  Replace a single document matching the filter.

  >>> async for doc in db.test.find({}):
  ...     print(doc)
  ...
  {'x': 1, '_id': ObjectId('54f4c5befba5220aa4d6dee7')}
  >>> result = await db.test.replace_one({'x': 1}, {'y': 1})
  >>> result.matched_count
  1
  >>> result.modified_count
  1
  >>> async for doc in db.test.find({}):
  ...     print(doc)
  ...
  {'y': 1, '_id': ObjectId('54f4c5befba5220aa4d6dee7')}

The *upsert* option can be used to insert a new document if a matching
document does not exist.

  >>> result = await db.test.replace_one({'x': 1}, {'x': 1}, True)
  >>> result.matched_count
  0
  >>> result.modified_count
  0
  >>> result.upserted_id
  ObjectId('54f11e5c8891e756a6e1abd4')
  >>> await db.test.find_one({'x': 1})
  {'x': 1, '_id': ObjectId('54f11e5c8891e756a6e1abd4')}

:param filter: A query that matches the document to replace.
:param replacement: The new document.
:param upsert: If ``True``, perform an insert if no documents
    match the filter.
:param bypass_document_validation: (optional) If ``True``, allows the
    write to opt-out of document level validation. Default is
    ``False``.
:param collation: An instance of
    :class:`~pymongo.collation.Collation`.
:param hint: 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.asynchronous.collection.AsyncCollection.create_index` (e.g.
    ``[('field', ASCENDING)]``). This option is only supported on
    MongoDB 4.2 and above.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param let: Map of parameter names and values. Values must be
    constant or closed expressions that do not reference document
    fields. Parameters can then be accessed as variables in an
    aggregate expression context (e.g. "$$var").
:param comment: A user-provided comment to attach to this
    command.
:param sort: Specify which document the operation updates if the query matches
    multiple documents. The first document matched by the sort order will be updated.
    This option is only supported on MongoDB 8.0 and above.
:return: - An instance of :class:`~pymongo.results.UpdateResult`.

.. versionchanged:: 4.11
   Added ``sort`` parameter.
.. versionchanged:: 4.1
   Added ``let`` parameter.
   Added ``comment`` parameter.
.. versionchanged:: 3.11
   Added ``hint`` parameter.
.. versionchanged:: 3.6
   Added ``session`` parameter.
.. versionchanged:: 3.4
  Added the `collation` option.
.. versionchanged:: 3.2
  Added bypass_document_validation support.

.. versionadded:: 3.0
filterNr  )r   r1  r   rX  r   r  rZ  r   )	r   r  validate_ok_for_replacer   rE   rj  r=   UPDATEr8  )r   rm  replacementrP  r$  r   rX  r   r  rZ  r   r   s               r]   replace_oneAsyncCollection.replace_onef  s     l 	""8V4&&{3?&&uc2//8((

+9# )   &&
 	
s   B	B!BB!c                B  #    [         R                  " SU5        [         R                  " U5        [         R                  " SU5        U R	                  U5      n[        U R                  UU[        R                  UUUUUUUU	U
US9I Sh  vN UR                  5      $  N7f)af  Update a single document matching the filter.

  >>> async for doc in db.test.find():
  ...     print(doc)
  ...
  {'x': 1, '_id': 0}
  {'x': 1, '_id': 1}
  {'x': 1, '_id': 2}
  >>> result = await db.test.update_one({'x': 1}, {'$inc': {'x': 3}})
  >>> result.matched_count
  1
  >>> result.modified_count
  1
  >>> async for doc in db.test.find():
  ...     print(doc)
  ...
  {'x': 4, '_id': 0}
  {'x': 1, '_id': 1}
  {'x': 1, '_id': 2}

If ``upsert=True`` and no documents match the filter, create a
new document based on the filter criteria and update modifications.

  >>> result = await db.test.update_one({'x': -10}, {'$inc': {'x': 3}}, upsert=True)
  >>> result.matched_count
  0
  >>> result.modified_count
  0
  >>> result.upserted_id
  ObjectId('626a678eeaa80587d4bb3fb7')
  >>> await db.test.find_one(result.upserted_id)
  {'_id': ObjectId('626a678eeaa80587d4bb3fb7'), 'x': -7}

:param filter: A query that matches the document to update.
:param update: The modifications to apply.
:param upsert: If ``True``, perform an insert if no documents
    match the filter.
:param bypass_document_validation: (optional) If ``True``, allows the
    write to opt-out of document level validation. Default is
    ``False``.
:param collation: An instance of
    :class:`~pymongo.collation.Collation`.
:param array_filters: A list of filters specifying which
    array elements an update should apply.
:param hint: 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.asynchronous.collection.AsyncCollection.create_index` (e.g.
    ``[('field', ASCENDING)]``). This option is only supported on
    MongoDB 4.2 and above.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param let: Map of parameter names and values. Values must be
    constant or closed expressions that do not reference document
    fields. Parameters can then be accessed as variables in an
    aggregate expression context (e.g. "$$var").
:param sort: Specify which document the operation updates if the query matches
    multiple documents. The first document matched by the sort order will be updated.
    This option is only supported on MongoDB 8.0 and above.
:param comment: A user-provided comment to attach to this
    command.

:return: - An instance of :class:`~pymongo.results.UpdateResult`.

.. versionchanged:: 4.11
   Added ``sort`` parameter.
.. versionchanged:: 4.1
   Added ``let`` parameter.
   Added ``comment`` parameter.
.. versionchanged:: 3.11
   Added ``hint`` parameter.
.. versionchanged:: 3.9
   Added the ability to accept a pipeline as the ``update``.
.. versionchanged:: 3.6
   Added the ``array_filters`` and ``session`` parameters.
.. versionchanged:: 3.4
  Added the ``collation`` option.
.. versionchanged:: 3.2
  Added ``bypass_document_validation`` support.

.. versionadded:: 3.0
rm  rb  )	r   r1  r   rb  rX  r   r  rZ  r   N
r   r  validate_ok_for_updatevalidate_list_or_noner   rE   rj  r=   ro  r8  )r   rm  r	  rP  r$  r   rb  rX  r   r  rZ  r   r   s                r]   
update_oneAsyncCollection.update_one  s     @ 	""8V4%%f-$$_mD//8((

+9#+ )   &&!
 	
   BB	B
Bc                B  #    [         R                  " SU5        [         R                  " U5        [         R                  " SU5        U R	                  U5      n[        U R                  UU[        R                  USUUUUUUU	U
S9I Sh  vN UR                  5      $  N7f)a}  Update one or more documents that match the filter.

  >>> async for doc in db.test.find():
  ...     print(doc)
  ...
  {'x': 1, '_id': 0}
  {'x': 1, '_id': 1}
  {'x': 1, '_id': 2}
  >>> result = await db.test.update_many({'x': 1}, {'$inc': {'x': 3}})
  >>> result.matched_count
  3
  >>> result.modified_count
  3
  >>> async for doc in db.test.find():
  ...     print(doc)
  ...
  {'x': 4, '_id': 0}
  {'x': 4, '_id': 1}
  {'x': 4, '_id': 2}

:param filter: A query that matches the documents to update.
:param update: The modifications to apply.
:param upsert: If ``True``, perform an insert if no documents
    match the filter.
:param bypass_document_validation: If ``True``, allows the
    write to opt-out of document level validation. Default is
    ``False``.
:param collation: An instance of
    :class:`~pymongo.collation.Collation`.
:param array_filters: A list of filters specifying which
    array elements an update should apply.
:param hint: 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.asynchronous.collection.AsyncCollection.create_index` (e.g.
    ``[('field', ASCENDING)]``). This option is only supported on
    MongoDB 4.2 and above.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param let: Map of parameter names and values. Values must be
    constant or closed expressions that do not reference document
    fields. Parameters can then be accessed as variables in an
    aggregate expression context (e.g. "$$var").
:param comment: A user-provided comment to attach to this
    command.

:return: - An instance of :class:`~pymongo.results.UpdateResult`.

.. versionchanged:: 4.1
   Added ``let`` parameter.
   Added ``comment`` parameter.
.. versionchanged:: 3.11
   Added ``hint`` parameter.
.. versionchanged:: 3.9
   Added the ability to accept a pipeline as the `update`.
.. versionchanged:: 3.6
   Added ``array_filters`` and ``session`` parameters.
.. versionchanged:: 3.4
  Added the `collation` option.
.. versionchanged:: 3.2
  Added bypass_document_validation support.

.. versionadded:: 3.0
rm  rb  T)	rS  r   r1  r   rb  rX  r   r  r   Nrt  )r   rm  r	  rP  rb  r$  r   rX  r   r  r   r   s               r]   update_manyAsyncCollection.update_manyK  s     Z 	""8V4%%f-$$_mD//8((

+9#+ )   &&!
 	
ry  c                   #    U R                   R                  R                  U R                   R                  U R                  U R
                  U R                  U R                  5      nUR                  U R                  XUS9I Sh  vN   g N7f)a  Alias for :meth:`~pymongo.asynchronous.database.AsyncDatabase.drop_collection`.

:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param encrypted_fields: **(BETA)** Document that describes the encrypted fields for
    Queryable Encryption.

The following two calls are equivalent:

  >>> await db.foo.drop()
  >>> await db.drop_collection("foo")

.. versionchanged:: 4.2
   Added ``encrypted_fields`` parameter.

.. versionchanged:: 4.1
   Added ``comment`` parameter.

.. versionchanged:: 3.7
   :meth:`drop` now respects this :class:`AsyncCollection`'s :attr:`write_concern`.

.. versionchanged:: 3.6
   Added ``session`` parameter.
)r   r   r  N)
r   r   get_databaser   r}   r~   r   r   drop_collectionr   )r   r   r   r  dbos        r]   dropAsyncCollection.drop  s~     @ nn##00NN  
 !!JJK[ " 
 	
 	
s   BBBBc           
       #    [         R                  " SU5        U=(       d    U R                  nUR                  nU[	        U(       + 5      S.n[        U5      nUb  U(       d  [        S5      eX~S'   UbQ  U(       d  UR                  S:  a  [        S5      e[        U[        5      (       d  [        R                  " U5      nXS'   U R                  Xn/S	.nUb  [         R                  " S
U5        XS
'   Ub  XS'   UR                  U R                  R                  UUU R                   U	U R                  R"                  U
S9I Sh  vN n[%        U5        U$  N7f)Internal delete helper.rm  )rQ  limitNrT  r   	   zPMust be connected to MongoDB 4.4+ to use hint on unacknowledged delete commands.rX  )deleter#  deletesr  r   r/  )r   r  r   r8  intr*   r-   r  r   r   r    r_  r   r@  r   r   r   r   r1   )r   r   ra  rS  r   r;  r#  r   rX  r   r   r  r   r8  
delete_docr   r0  s                    r]   _deleteAsyncCollection._delete  sM      	""8X6%;););$11#ce)n=
.y9	 ()^__*3;'D$9$9A$=(f  dC((%55d;!%v!YY7|T?,,UC8 EN!(I ||NN'<<>>((+ $ 
 
 	&f-
s   EEEEc                "  ^ ^^^^^^^^	^
#            SUU
UUU	UUUU U4
S jjnT R                   R                  R                  T=(       d    T R                  R                  =(       a    T(       + UU[
        R                  S9I Sh  vN $  N7f)r  c                T   >
#    TR                  UTTTT	T
TTU UTTS9I S h  vN $  N7f)N)	r   r;  r#  r   rX  r   r   r  r   )r  )r   r   r   r   r   ra  rX  r  rS  r;  r#  r   r   s      r]   r  2AsyncCollection._delete_retryable.<locals>._delete"  sL      +# / &    s   (&(r  N)r   r4  r   rb   r   r5  r6  Mapping[str, Any])r   r   r9  r   r8  r=   DELETE)r   ra  rS  r   r;  r#  r   rX  r   r  r   r  s   ```````` `` r]   _delete_retryable!AsyncCollection._delete_retryable  s     	1	9H	[_		 	 	$ ^^**;;0d00>>Lu9jj	 < 
 
 	
 
s   A<BB	Bc                   #    U R                  U5      n[        U R                  USUUUUUUS9I Sh  vN UR                  5      $  N7f)a  Delete a single document matching the filter.

  >>> await db.test.count_documents({'x': 1})
  3
  >>> result = await db.test.delete_one({'x': 1})
  >>> result.deleted_count
  1
  >>> await db.test.count_documents({'x': 1})
  2

:param filter: A query that matches the document to delete.
:param collation: An instance of
    :class:`~pymongo.collation.Collation`.
:param hint: 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.asynchronous.collection.AsyncCollection.create_index` (e.g.
    ``[('field', ASCENDING)]``). This option is only supported on
    MongoDB 4.4 and above.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param let: Map of parameter names and values. Values must be
    constant or closed expressions that do not reference document
    fields. Parameters can then be accessed as variables in an
    aggregate expression context (e.g. "$$var").
:param comment: A user-provided comment to attach to this
    command.

:return: - An instance of :class:`~pymongo.results.DeleteResult`.

.. versionchanged:: 4.1
   Added ``let`` parameter.
   Added ``comment`` parameter.
.. versionchanged:: 3.11
   Added ``hint`` parameter.
.. versionchanged:: 3.6
   Added ``session`` parameter.
.. versionchanged:: 3.4
  Added the `collation` option.
.. versionadded:: 3.0
Fr   r   rX  r   r  r   Nr   rB   r  r8  r   rm  r   rX  r   r  r   r   s           r]   
delete_oneAsyncCollection.delete_one;  se     d //8((+# ) 	 	 &&
 	
	   0AAAc                   #    U R                  U5      n[        U R                  USUUUUUUS9I Sh  vN UR                  5      $  N7f)a  Delete one or more documents matching the filter.

  >>> await db.test.count_documents({'x': 1})
  3
  >>> result = await db.test.delete_many({'x': 1})
  >>> result.deleted_count
  3
  >>> await db.test.count_documents({'x': 1})
  0

:param filter: A query that matches the documents to delete.
:param collation: An instance of
    :class:`~pymongo.collation.Collation`.
:param hint: 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.asynchronous.collection.AsyncCollection.create_index` (e.g.
    ``[('field', ASCENDING)]``). This option is only supported on
    MongoDB 4.4 and above.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param let: Map of parameter names and values. Values must be
    constant or closed expressions that do not reference document
    fields. Parameters can then be accessed as variables in an
    aggregate expression context (e.g. "$$var").
:param comment: A user-provided comment to attach to this
    command.

:return: - An instance of :class:`~pymongo.results.DeleteResult`.

.. versionchanged:: 4.1
   Added ``let`` parameter.
   Added ``comment`` parameter.
.. versionchanged:: 3.11
   Added ``hint`` parameter.
.. versionchanged:: 3.6
   Added ``session`` parameter.
.. versionchanged:: 3.4
  Added the `collation` option.
.. versionadded:: 3.0
Tr  Nr  r  s           r]   delete_manyAsyncCollection.delete_many|  se     d //8((+# ) 	 	 &&
 	
	r  c                   #    Ub#  [        U[        R                  5      (       d  SU0nU R                  " U/UQ70 UD6nUR	                  S5        Sh  vN nUs  $  N
 g7f)a  Get a single document from the database.

All arguments to :meth:`find` are also valid arguments for
:meth:`find_one`, although any `limit` argument will be
ignored. Returns a single document, or ``None`` if no matching
document is found.

The :meth:`find_one` method obeys the :attr:`read_preference` of
this :class:`AsyncCollection`.

:param filter: a dictionary specifying
    the query to be performed OR any other type to be used as
    the value for a query for ``"_id"``.

:param args: any additional positional arguments
    are the same as the arguments to :meth:`find`.

:param kwargs: any additional keyword arguments
    are the same as the arguments to :meth:`find`.

    :: code-block: python

      >>> await collection.find_one(max_time_ms=100)

Nr  rt   )r   r   r   findr  )r   rm  r   r   cursorr0  s         r]   find_oneAsyncCollection.find_one  sa     8 j&E&EV_F63D3F3"LL, 	&M	,s*   AA!AAAA!AA!c                     [        U /UQ70 UD6$ )a#  Query the database.

The `filter` argument is a query document that all results
must match. For example:

>>> db.test.find({"hello": "world"})

only matches documents that have a key "hello" with value
"world".  Matches can have other keys *in addition* to
"hello". The `projection` argument is used to specify a subset
of fields that should be included in the result documents. By
limiting results to a certain subset of fields you can cut
down on network traffic and decoding time.

Raises :class:`TypeError` if any of the arguments are of
improper type. Returns an instance of
:class:`~pymongo.asynchronous.cursor.AsyncCursor` corresponding to this query.

The :meth:`find` method obeys the :attr:`read_preference` of
this :class:`AsyncCollection`.

:param filter: A query document that selects which documents
    to include in the result set. Can be an empty document to include
    all documents.
:param projection: a list of field names that should be
    returned in the result set or a dict specifying the fields
    to include or exclude. If `projection` is a list "_id" will
    always be returned. Use a dict to exclude fields from
    the result (e.g. projection={'_id': False}).
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param skip: the number of documents to omit (from
    the start of the result set) when returning the results
:param limit: the maximum number of results to
    return. A limit of 0 (the default) is equivalent to setting no
    limit.
:param no_cursor_timeout: if False (the default), any
    returned cursor is closed by the server after 10 minutes of
    inactivity. If set to True, the returned cursor will never
    time out on the server. Care should be taken to ensure that
    cursors with no_cursor_timeout turned on are properly closed.
:param cursor_type: the type of cursor to return. The valid
    options are defined by :class:`~pymongo.cursor.CursorType`:

    - :attr:`~pymongo.cursor.CursorType.NON_TAILABLE` - the result of
      this find call will return a standard cursor over the result set.
    - :attr:`~pymongo.cursor.CursorType.TAILABLE` - the result of this
      find call will be a tailable cursor - tailable cursors are only
      for use with capped collections. They are not closed when the
      last data is retrieved but are kept open and the cursor location
      marks the final document position. If more data is received
      iteration of the cursor will continue from the last document
      received. For details, see the `tailable cursor documentation
      <https://www.mongodb.com/docs/manual/core/tailable-cursors/>`_.
    - :attr:`~pymongo.cursor.CursorType.TAILABLE_AWAIT` - the result
      of this find call will be a tailable cursor with the await flag
      set. The server will wait for a few seconds after returning the
      full result set so that it can capture and return additional data
      added during the query.
    - :attr:`~pymongo.cursor.CursorType.EXHAUST` - the result of this
      find call will be an exhaust cursor. MongoDB will stream batched
      results to the client without waiting for the client to request
      each batch, reducing latency. See notes on compatibility below.

:param sort: a list of (key, direction) pairs
    specifying the sort order for this query. See
    :meth:`~pymongo.asynchronous.cursor.AsyncCursor.sort` for details.
:param allow_partial_results: if True, mongos will return
    partial results if some shards are down instead of returning an
    error.
:param oplog_replay: **DEPRECATED** - if True, set the
    oplogReplay query flag. Default: False.
:param batch_size: Limits the number of documents returned in
    a single batch.
:param collation: An instance of
    :class:`~pymongo.collation.Collation`.
:param return_key: If True, return only the index keys in
    each document.
:param show_record_id: If True, adds a field ``$recordId`` in
    each document with the storage engine's internal record identifier.
:param snapshot: **DEPRECATED** - If True, prevents the
    cursor from returning a document more than once because of an
    intervening write operation.
:param hint: An index, in the same format as passed to
    :meth:`~pymongo.asynchronous.collection.AsyncCollection.create_index` (e.g.
    ``[('field', ASCENDING)]``). Pass this as an alternative to calling
    :meth:`~pymongo.asynchronous.cursor.AsyncCursor.hint` on the cursor to tell Mongo the
    proper index to use for the query.
:param max_time_ms: Specifies a time limit for a query
    operation. If the specified time is exceeded, the operation will be
    aborted and :exc:`~pymongo.errors.ExecutionTimeout` is raised. Pass
    this as an alternative to calling
    :meth:`~pymongo.asynchronous.cursor.AsyncCursor.max_time_ms` on the cursor.
:param max_scan: **DEPRECATED** - The maximum number of
    documents to scan. Pass this as an alternative to calling
    :meth:`~pymongo.asynchronous.cursor.AsyncCursor.max_scan` on the cursor.
:param min: A list of field, limit pairs specifying the
    inclusive lower bound for all keys of a specific index in order.
    Pass this as an alternative to calling
    :meth:`~pymongo.asynchronous.cursor.AsyncCursor.min` on the cursor. ``hint`` must
    also be passed to ensure the query utilizes the correct index.
:param max: A list of field, limit pairs specifying the
    exclusive upper bound for all keys of a specific index in order.
    Pass this as an alternative to calling
    :meth:`~pymongo.asynchronous.cursor.AsyncCursor.max` on the cursor. ``hint`` must
    also be passed to ensure the query utilizes the correct index.
:param comment: A string to attach to the query to help
    interpret and trace the operation in the server logs and in profile
    data. Pass this as an alternative to calling
    :meth:`~pymongo.asynchronous.cursor.AsyncCursor.comment` on the cursor.
:param allow_disk_use: if True, MongoDB may use temporary
    disk files to store data exceeding the system memory limit while
    processing a blocking sort operation. The option has no effect if
    MongoDB can satisfy the specified sort using an index, or if the
    blocking sort requires less memory than the 100 MiB limit. This
    option is only supported on MongoDB 4.4 and above.

.. note:: There are a number of caveats to using
  :attr:`~pymongo.cursor.CursorType.EXHAUST` as cursor_type:

  - The `limit` option can not be used with an exhaust cursor.

  - Exhaust cursors are not supported by mongos and can not be
    used with a sharded cluster.

  - A :class:`~pymongo.cursor.AsyncCursor` instance created with the
    :attr:`~pymongo.cursor.CursorType.EXHAUST` cursor_type requires an
    exclusive :class:`~socket.socket` connection to MongoDB. If the
    :class:`~pymongo.asynchronous.cursor.AsyncCursor` is discarded without being
    completely iterated the underlying :class:`~socket.socket`
    connection will be closed and discarded without being returned to
    the connection pool.

.. versionchanged:: 4.0
   Removed the ``modifiers`` option.
   Empty projections (eg {} or []) are passed to the server as-is,
   rather than the previous behavior which substituted in a
   projection of ``{"_id": 1}``. This means that an empty projection
   will now return the entire document, not just the ``"_id"`` field.

.. versionchanged:: 3.11
   Added the ``allow_disk_use`` option.
   Deprecated the ``oplog_replay`` option. Support for this option is
   deprecated in MongoDB 4.4. The query engine now automatically
   optimizes queries against the oplog without requiring this
   option to be set.

.. versionchanged:: 3.7
   Deprecated the ``snapshot`` option, which is deprecated in MongoDB
   3.6 and removed in MongoDB 4.0.
   Deprecated the ``max_scan`` option. Support for this option is
   deprecated in MongoDB 4.0. Use ``max_time_ms`` instead to limit
   server-side execution time.

.. versionchanged:: 3.6
   Added ``session`` parameter.

.. versionchanged:: 3.5
   Added the options ``return_key``, ``show_record_id``, ``snapshot``,
   ``hint``, ``max_time_ms``, ``max_scan``, ``min``, ``max``, and
   ``comment``.
   Deprecated the ``modifiers`` option.

.. versionchanged:: 3.4
   Added support for the ``collation`` option.

.. versionchanged:: 3.0
   Changed the parameter names ``spec``, ``fields``, ``timeout``, and
   ``partial`` to ``filter``, ``projection``, ``no_cursor_timeout``,
   and ``allow_partial_results`` respectively.
   Added the ``cursor_type``, ``oplog_replay``, and ``modifiers``
   options.
   Removed the ``network_timeout``, ``read_preference``, ``tag_sets``,
   ``secondary_acceptable_latency_ms``, ``max_scan``, ``snapshot``,
   ``tailable``, ``await_data``, ``exhaust``, ``as_class``, and
   slave_okay parameters.
   Removed ``compile_re`` option: PyMongo now always
   represents BSON regular expressions as :class:`~bson.regex.Regex`
   objects. Use :meth:`~bson.regex.Regex.try_compile` to attempt to
   convert from a BSON regular expression to a Python regular
   expression object.
   Soft deprecated the ``manipulate`` option.

.. seealso:: The MongoDB documentation on `find <https://dochub.mongodb.org/core/find>`_.
)r(   r   s      r]   r  AsyncCollection.find  s    t 41$1&11r\   c                    U R                   R                  R                  (       a  [        S5      e[	        U /UQ70 UD6$ )a  Query the database and retrieve batches of raw BSON.

Similar to the :meth:`find` method but returns a
:class:`~pymongo.asynchronous.cursor.AsyncRawBatchCursor`.

This example demonstrates how to work with raw batches, but in practice
raw batches should be passed to an external library that can decode
BSON into another data type, rather than used with PyMongo's
:mod:`bson` module.

  >>> import bson
  >>> cursor = db.test.find_raw_batches()
  >>> async for batch in cursor:
  ...     print(bson.decode_all(batch))

.. note:: find_raw_batches does not support auto encryption.

.. versionchanged:: 3.12
   Instead of ignoring the user-specified read concern, this method
   now sends it to the server when connected to MongoDB 3.6+.

   Added session support.

.. versionadded:: 3.6
z1find_raw_batches does not support auto encryption)r   r   
_encrypterr/   r)   r   s      r]   find_raw_batches AsyncCollection.find_raw_batches  s8    6 >>  ++"#VWW"49$9&99r\   c           
        #    U R                  UUUU R                  U R                  UUS9I Sh  vN n[        US   5      $  N7f)zInternal count command helper.)r~   r}   r   r   r   Nr\  )r  r   r   r  )r   r   r   r~   r   r   ress          r]   
_count_cmdAsyncCollection._count_cmd  sU      MM+<<** " 
 
 3s8}
s   -AAAc                   #    U R                  UUUS/U R                  U R                  UUS9I Sh  vN nSU;  a  gUS   S   nU(       a  US   $ S$  N!7f)zAInternal helper to run an aggregate that returns a single result.   )r   r}   r   r   r   Nr  
firstBatchr   )r  r   r   )r   r   r~   r   r   r   r0  batchs           r]   _aggregate_one_result%AsyncCollection._aggregate_one_result  sw      }} T<<** % 	
 	
 6!x . uQx*d*	
s   /AA"Ac                   ^ ^#    ST;   a  [        S5      eUb  UTS'             SUU 4S jjnT R                  US[        R                  S9I Sh  vN $  N7f)a  Get an estimate of the number of documents in this collection using
collection metadata.

The :meth:`estimated_document_count` method is **not** supported in a
transaction.

All optional parameters should be passed as keyword arguments
to this method. Valid options include:

  - `maxTimeMS` (int): The maximum amount of time to allow this
    operation to run, in milliseconds.

:param comment: A user-provided comment to attach to this
    command.
:param kwargs: See list of options above.

.. versionchanged:: 4.2
   This method now always uses the `count`_ command. Due to an oversight in versions
   5.0.0-5.0.8 of MongoDB, the count command was not included in V1 of the
   :ref:`versioned-api-ref`. Users of the Stable API with estimated_document_count are
   recommended to upgrade their server version to 5.0.9+ or set
   :attr:`pymongo.server_api.ServerApi.strict` to ``False`` to avoid encountering errors.

.. versionadded:: 3.7
.. _count: https://mongodb.com/docs/manual/reference/command/count/
r   z2estimated_document_count does not support sessionsNr   c                   >#    STR                   0nUR                  T5        TR                  XX4S S9I S h  vN $  N7f)Ncount)r   )r   r	  r  )r   _serverr   r~   r   r   r   s        r]   _cmd6AsyncCollection.estimated_document_count.<locals>._cmd  s>      $+DJJ"7CJJvX\]]]]s   4><>r  
r   r4  r  rc   r   rb   r~   Optional[_ServerMode]r6  r  )r-   _retryable_non_cursor_readr=   COUNT)r   r   r   r  s   ` ` r]   estimated_document_count(AsyncCollection.estimated_document_count  s     6 $%YZZ 'F9	^1	^	^ "	^ 3		^
 	^ 	^ 44T43994UUUUs   AAAAc                `  ^ ^^#    SU0/nSU;   a"  UR                  SUR                  S5      05        SU;   a"  UR                  SUR                  S5      05        Ub  X4S'   UR                  SS	S
S	0S.05        T R                  U0 S.mSU;   a4  [        US   [        5      (       d  [
        R                  " US   5      US'   [        UR                  SS5      5      mTR                  U5                  SUUU 4S jjnT R                  Xb[        R                  5      I Sh  vN $  N7f)aX	  Count the number of documents in this collection.

.. note:: For a fast count of the total documents in a collection see
   :meth:`estimated_document_count`.

The :meth:`count_documents` method is supported in a transaction.

All optional parameters should be passed as keyword arguments
to this method. Valid options include:

  - `skip` (int): The number of matching documents to skip before
    returning results.
  - `limit` (int): The maximum number of documents to count. Must be
    a positive integer. If not provided, no limit is imposed.
  - `maxTimeMS` (int): The maximum amount of time to allow this
    operation to run, in milliseconds.
  - `collation` (optional): An instance of
    :class:`~pymongo.collation.Collation`.
  - `hint` (string or list of tuples): The index to use. Specify either
    the index name as a string or the index specification as a list of
    tuples (e.g. [('a', pymongo.ASCENDING), ('b', pymongo.ASCENDING)]).

The :meth:`count_documents` method obeys the :attr:`read_preference` of
this :class:`AsyncCollection`.

.. note:: When migrating from :meth:`count` to :meth:`count_documents`
   the following query operators must be replaced:

   +-------------+-------------------------------------+
   | Operator    | Replacement                         |
   +=============+=====================================+
   | $where      | `$expr`_                            |
   +-------------+-------------------------------------+
   | $near       | `$geoWithin`_ with `$center`_       |
   +-------------+-------------------------------------+
   | $nearSphere | `$geoWithin`_ with `$centerSphere`_ |
   +-------------+-------------------------------------+

:param filter: A query document that selects which documents
    to count in the collection. Can be an empty document to count all
    documents.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: See list of options above.


.. versionadded:: 3.7

.. _$expr: https://mongodb.com/docs/manual/reference/operator/query/expr/
.. _$geoWithin: https://mongodb.com/docs/manual/reference/operator/query/geoWithin/
.. _$center: https://mongodb.com/docs/manual/reference/operator/query/center/
.. _$centerSphere: https://mongodb.com/docs/manual/reference/operator/query/centerSphere/
z$matchskipz$skipr  z$limitNr   z$grouprO   z$sum)r  r\  )	aggregater   r  rX  r   c                b   >#    TR                  X#TTU 5      I S h  vN nU(       d  gUS   $  N7f)Nr   r\  )r  )r   r  r   r~   r0  r   r   r   s        r]   r  -AsyncCollection.count_documents.<locals>._cmd`  s=       55sIw F #;s   /-/r  )rE  r  r   r   r   r    r_  r*   r	  r  r=   r  )	r   rm  r   r   r   r   r  r   r   s	   `      @@r]   count_documentsAsyncCollection.count_documents  s:    | v&'VOOWfjj&89:fOOXvzz'':;< '91FA;#?@A JJHKVJvf~s$C$C+;;F6NKF6N.vzz+t/LM	

6	1		 "	 3		
 	 	 44TCIINNNNs   D"D.'D,(D.c                  #    U R                   R                  nUR                  U5       ISh  vN nUR                  XR	                  U5      XS5      I Sh  vN sSSS5      ISh  vN   $  N> N N	! , ISh  vN  (       d  f       g= f7f)z;Non-cursor read helper to handle implicit session creation.N)r   r   r   _retryable_readr   )r   funcr   r   r   r   s         r]   r  *AsyncCollection._retryable_non_cursor_reado  se      &&&&w//1//6O6OPQ6RTUaa 0//a 0///sV   ,BA-B%A3A/A3B'A1(B/A31B3B
9A<:B
Bc                   #    [         R                  " SU5        Ub  X4S'   U R                  " X40 UD6I Sh  vN $  N7f)a  Create one or more indexes on this collection.

  >>> from pymongo import IndexModel, ASCENDING, DESCENDING
  >>> index1 = IndexModel([("hello", DESCENDING),
  ...                      ("world", ASCENDING)], name="hello_world")
  >>> index2 = IndexModel([("goodbye", DESCENDING)])
  >>> await db.test.create_indexes([index1, index2])
  ["hello_world", "goodbye_-1"]

:param indexes: A list of :class:`~pymongo.operations.IndexModel`
    instances.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: optional arguments to the createIndexes
    command (like maxTimeMS) can be passed as keyword arguments.




.. note:: The :attr:`~pymongo.asynchronous.collection.AsyncCollection.write_concern` of
   this collection is automatically applied to this operation.

.. versionchanged:: 3.6
   Added ``session`` parameter. Added support for arbitrary keyword
   arguments.

.. versionchanged:: 3.4
   Apply this collection's write concern automatically to this operation
   when connected to MongoDB >= 3.4.
.. versionadded:: 3.0

.. _createIndexes: https://mongodb.com/docs/manual/reference/command/createIndexes/
indexesNr   )r   r  _create_indexes)r   r  r   r   r   s        r]   create_indexesAsyncCollection.create_indexes}  sB     T 	Y0 '9))'EfEEEEs   5><>c           
       ^^#    / mU R                  U[        R                  S9I Sh  vN  ISh  vN nUR                  S:  nS	UU4S jjnU R                  [        U" 5       5      S.nUR                  U5        SU;   a  U(       d  [        S5      eU R                  UU[        R                  [        U R                  U5      US9I Sh  vN   SSS5      ISh  vN   T$  N N N N! , ISh  vN  (       d  f       T$ = f7f)
aA  Internal createIndexes helper.

:param indexes: A list of :class:`~pymongo.operations.IndexModel`
    instances.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param kwargs: optional arguments to the createIndexes
    command (like maxTimeMS) can be passed as keyword arguments.
r  Nr  c               3     >#    T HK  n [        U [        5      (       d  [        U < S35      eU R                  nTR	                  US   5        Uv   MM     g 7f)Nz4 is not an instance of pymongo.operations.IndexModelr   )r   r5   r   r?  rE  )indexr?  r  namess     r]   gen_indexes4AsyncCollection._create_indexes.<locals>.gen_indexes  sV     $E%eZ88'$i'[\   %~~HLL&!12"N %s   AA)createIndexesr  commitQuorumzRMust be connected to MongoDB 4.4+ to use the commitQuorum option for createIndexes)r~   r}   r   r   r6  zIterator[Mapping[str, Any]])r   r=   CREATE_INDEXESr  r   rJ  r	  r-   r  r?   r  r2   r   )	r   r  r   r   r   supports_quorumr  r   r  s	    `      @r]   r  AsyncCollection._create_indexes  s      ..w#BTBT.UUUUY]"33q8O# # %)II${}:MNCJJv'(< 
 -- . 6 6<"55g>     + VU: ; V*+ VUU: sg   $DC#DC%DBC+C'C+DC)D%D'C+)D+D1C42D>Dc                   #    0 nSU;   a  UR                  S5      US'   Ub  X5S'   [        U40 UD6nU R                  " U/U40 UD6I Sh  vN S   $  N7f)a  Creates an index on this collection.

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`).

To create a single key ascending index on the key ``'mike'`` we just
use a string argument::

  >>> await my_collection.create_index("mike")

For a compound index on ``'mike'`` descending and ``'eliot'``
ascending we need to use a list of tuples::

  >>> await my_collection.create_index([("mike", pymongo.DESCENDING),
  ...                             "eliot"])

All optional index creation parameters should be passed as
keyword arguments to this method. For example::

  >>> await my_collection.create_index([("mike", pymongo.DESCENDING)],
  ...                            background=True)

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` (optional): An instance of
    :class:`~pymongo.collation.Collation`.
  - `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.

.. warning:: `dropDups` is not supported by MongoDB 3.0 or newer. The
  option is silently ignored by the server and unique index builds
  using the option will fail if a duplicate value is detected.

.. note:: The :attr:`~pymongo.asynchronous.collection.AsyncCollection.write_concern` of
   this collection is automatically applied to this operation.

:param keys: a single key or a list of (key, direction)
    pairs specifying the index to create
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: any additional index creation
    options (see the above list) should be passed as keyword
    arguments.

.. versionchanged:: 4.4
   Allow passing a list containing (key, direction) pairs
   or keys for the ``keys`` parameter.
.. versionchanged:: 4.1
   Added ``comment`` parameter.
.. versionchanged:: 3.11
   Added the ``hidden`` option.
.. versionchanged:: 3.6
   Added ``session`` parameter. Added support for passing maxTimeMS
   in kwargs.
.. versionchanged:: 3.4
   Apply this collection's write concern automatically to this operation
   when connected to MongoDB >= 3.4. Support the `collation` option.
.. versionchanged:: 3.2
   Added partialFilterExpression to support partial indexes.
.. versionchanged:: 3.0
   Renamed `key_or_list` to `keys`. Removed the `cache_for` option.
   :meth:`create_index` no longer caches index names. Removed support
   for the drop_dups and bucket_size aliases.

.. seealso:: The MongoDB documentation on `indexes <https://dochub.mongodb.org/core/indexes>`_.

.. _wildcard index: https://dochub.mongodb.org/core/index-wildcard/
	maxTimeMSNr   r   )r  r5   r  )r   keysr   r   r   cmd_optionsr  s          r]   r  AsyncCollection.create_index  sj     \ & '-zz+'>K$%,	"4*6***E7GK{KKQOOKs   AA
AAc                V   #    Ub  X#S'   U R                   " SSU0UD6I Sh  vN   g N7f)a6  Drops all indexes on this collection.

Can be used on non-existent collections or collections with no indexes.
Raises OperationFailure on an error.

:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: optional arguments to the createIndexes
    command (like maxTimeMS) can be passed as keyword arguments.

.. note:: The :attr:`~pymongo.asynchronous.collection.AsyncCollection.write_concern` of
   this collection is automatically applied to this operation.

.. versionchanged:: 3.6
   Added ``session`` parameter. Added support for arbitrary keyword
   arguments.

.. versionchanged:: 3.4
   Apply this collection's write concern automatically to this operation
   when connected to MongoDB >= 3.4.
Nr   r   )*_drop_index)r   r   r   r   s       r]   drop_indexesAsyncCollection.drop_indexesO	  s1     :  '9>G>v>>>s   )')c                H   #    U R                   " XU40 UD6I Sh  vN   g N7f)aV  Drops the specified index on this collection.

Can be used on non-existent collections or collections with no
indexes.  Raises OperationFailure on an error (e.g. trying to
drop an index that does not exist). `index_or_name`
can be either an index name (as returned by `create_index`),
or an index specifier (as passed to `create_index`). An index
specifier should be a list of (key, direction) pairs. Raises
TypeError if index is not an instance of (str, unicode, list).

.. warning::

  if a custom name was used on index creation (by
  passing the `name` parameter to :meth:`create_index`) the index
  **must** be dropped by name.

:param index_or_name: index (or name of index) to drop
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: optional arguments to the createIndexes
    command (like maxTimeMS) can be passed as keyword arguments.



.. note:: The :attr:`~pymongo.asynchronous.collection.AsyncCollection.write_concern` of
   this collection is automatically applied to this operation.


.. versionchanged:: 3.6
   Added ``session`` parameter. Added support for arbitrary keyword
   arguments.

.. versionchanged:: 3.4
   Apply this collection's write concern automatically to this operation
   when connected to MongoDB >= 3.4.

Nr  )r   index_or_namer   r   r   s        r]   
drop_indexAsyncCollection.drop_indexp	  s#     ^ }wI&IIIs   " "c           
     D  #    Un[        U[        5      (       a  [        R                  " U5      n[        U[        5      (       d  [        S[        U5       35      eU R                  US.nUR                  U5        Ub  X6S'   U R                  U[        R                  S9I S h  vN  IS h  vN nU R                  UU[        R                  SS/U R                  U5      US9I S h  vN   S S S 5      IS h  vN   g  NY NR N N! , IS h  vN  (       d  f       g = f7f)Nz6index_or_name must be an instance of str or list, not )dropIndexesr  r   r  ns not foundr  )r~   r   r   r   )r   rJ  r    _gen_index_namer   r   r   r   r	  r   r=   DROP_INDEXESr  r?   r  r   )r   r  r   r   r   r   r   r   s           r]   r  AsyncCollection._drop_index	  s      mT**!11-@D$$$TUYZ^U_T`abb"jj48

6$	N..w#BRBR.SSSSW[-- . 6 6"0"!5"55g>      TSS TSSSsl   B"D $C>%D -D .D 17D(D)D-D 8D9D  D DD DDDD c                @   #    U R                  X5      I Sh  vN $  N7f)aT  Get a cursor over the index documents for this collection.

  >>> async for index in await db.test.list_indexes():
  ...     print(index)
  ...
  SON([('v', 2), ('key', SON([('_id', 1)])), ('name', '_id_')])

:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.

:return: An instance of :class:`~pymongo.asynchronous.command_cursor.AsyncCommandCursor`.

.. versionchanged:: 4.1
   Added ``comment`` parameter.

.. versionchanged:: 3.6
   Added ``session`` parameter.

.. versionadded:: 3.0
N)_list_indexes)r   r   r   s      r]   list_indexesAsyncCollection.list_indexes	  s     6 ''9999s   c                |  ^ ^^^^#    [        [        5      m[        [        [        [
        [        4      T R                  T[        R                  S95      mU=(       a    UR                  5       =(       d    [        R                  nUS Lm          SUUUUU 4S jjnT R                  R                  R                  US5       IS h  vN nT R                  R                  R                  XCU[        R                   S9I S h  vN sS S S 5      IS h  vN   $  NP N N	! , IS h  vN  (       d  f       g = f7f)N)r}   r~   c           
     \  >#    TR                   0 S.nT
b  T
US'    TR                  X$UTU S9I S h  vN S   n[	        T	UUR
                  U TUR                  S5      S9nUR                  U5      I S h  vN   U$  NI! [         a   nUR                  S:w  a  e S/ S.n S nANiS nAff = f N57f)	N)listIndexesr  r   )r   r  r  r   )idr  )r   explicit_sessionr   )r   r  r0   coder&   addressr   _maybe_pin_connection)r   r  r   r~   r   r  exc
cmd_cursorr}   collr   r  r   s           r]   r  +AsyncCollection._list_indexes.<locals>._cmd	  s      #'**;C"!(I	5--?M[b-cc ,!1	*J 224888# d# 5 88r> !45 9sI   B,A= A;A= ;B,4B*5B,;A= =
B'B"B,"B''B,Fr  )
r   r4  r  rc   r   rb   r~   r@   r6  ,AsyncCommandCursor[MutableMapping[str, Any]])r   r   r   rg   r   r   r   r   r?   r  _txn_read_preferencer   r   r   r  r=   LIST_INDEXES)	r   r   r   	read_prefr  r   r}   r  r  s	   ` `   @@@r]   r  AsyncCollection._list_indexes	  s    
 '33&7N3845M>KaKab
 ?!=!=!?ZNDZDZ	"$.	1		 "	 )		
 :	 	> >>((55guEE..>>c.>.> ?   FEE FEEEsZ   CD<DD<7D"DD"
D<D D<D" D<"D9(D+)D95D<c                   #    U R                  XS9I Sh  vN n0 nU  Sh  vN n[        US   R                  5       5      US'   [        U5      nXTUR	                  S5      '   MH   NP NE
 U$ 7f)a  Get information on this collection's indexes.

Returns a dictionary where the keys are index names (as
returned by create_index()) and the values are dictionaries
containing information about each index. The dictionary is
guaranteed to contain at least a single key, ``"key"`` which
is a list of (key, direction) pairs specifying the index (as
passed to create_index()). It will also contain any other
metadata about the indexes, except for the ``"ns"`` and
``"name"`` keys, which are cleaned. Example output might look
like this:

>>> await db.test.create_index("x", unique=True)
'x_1'
>>> await db.test.index_information()
{'_id_': {'key': [('_id', 1)]},
 'x_1': {'unique': True, 'key': [('x', 1)]}}

:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.

.. versionchanged:: 4.1
   Added ``comment`` parameter.

.. versionchanged:: 3.6
   Added ``session`` parameter.
)r   r   Nr  r   )r  rJ  itemsr   r  )r   r   r   r  infor  s         r]   index_information!AsyncCollection.index_information
  sv     D ))')KK! 	,%e 2 2 45E%LKE&+6"# L	,6 s0   A-A&A-A*A(A*AA-(A**A-c                  #    Uc  S0 0/nOSSU00/nU R                  [        [        R                  [        [
        S9n[        U[        UUUSLUSSS00S9nU R                  R                  R                  UR                  UR                  U5      UUR                  (       + [        R                  S	9I Sh  vN $  N7f)
ah  Return a cursor over search indexes for the current collection.

:param name: If given, the name of the index to search
    for.  Only indexes with matching index names will be returned.
    If not given, all search indexes for the current collection
    will be returned.
:param session: a :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.

:return: A :class:`~pymongo.asynchronous.command_cursor.AsyncCommandCursor` over the result
  set.

.. note:: requires a MongoDB server version 7.0+ Atlas cluster.

.. versionadded:: 4.5
Nz$listSearchIndexesr   )r}   r~   r   r   r  r  rO   )r  r   r   	retryabler   )r   r   r?   r  rJ   r>   r"   r&   r   r   r  
get_cursorget_read_preference_performs_writer=   LIST_SEARCH_INDEX)r   r   r   r   r   r   r  r   s           r]   list_search_indexes#AsyncCollection.list_search_indexes6
  s     0 <$8"#=">H-~>?H  /*22/-	 ! 
 ,$D0!L!#45
 ^^**::NN##G,---++ ; 
 
 	
 
s   B6B?8B=9B?c                   #    [        U[        5      (       d  [        S0 UD6nU R                  " U/X#40 UD6I Sh  vN S   $  N7f)a  Create a single search index for the current collection.

:param model: The model for the new search index.
    It can be given as a :class:`~pymongo.operations.SearchIndexModel`
    instance or a dictionary with a model "definition"  and optional
    "name".
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: optional arguments to the createSearchIndexes
    command (like maxTimeMS) can be passed as keyword arguments.

:return: The name of the new search index.

.. note:: requires a MongoDB server version 7.0+ Atlas cluster.

.. versionadded:: 4.5
Nr   rS   )r   r8   _create_search_indexes)r   modelr   r   r   s        r]   create_search_index#AsyncCollection.create_search_indexk
  sH     4 %!122$-u-E115'7VvVVXYZZVs   9AAAc                F   #    U R                   " XU40 UD6I Sh  vN $  N7f)a9  Create multiple search indexes for the current collection.

:param models: A list of :class:`~pymongo.operations.SearchIndexModel` instances.
:param session: a :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: optional arguments to the createSearchIndexes
    command (like maxTimeMS) can be passed as keyword arguments.

:return: A list of the newly created search index names.

.. note:: requires a MongoDB server version 7.0+ Atlas cluster.

.. versionadded:: 4.5
N)r  )r   modelsr   r   r   s        r]   create_search_indexes%AsyncCollection.create_search_indexes
  s%     , 00'TVTTTTs   !!c                  ^#    Ub  X4S'   SU4S jjnU R                   [        U" 5       5      S.nUR                  U5        U R                  U[        R
                  S9I S h  vN  IS h  vN nU R                  UU[        R                  [        S9I S h  vN nUS    V	s/ s H  oS   PM	     sn	sS S S 5      IS h  vN   $  Nb N[ N1s  sn	f  N! , IS h  vN  (       d  f       g = f7f)	Nr   c               3     >#    T H5  n [        U [        5      (       d  [        U < S35      eU R                  v   M7     g 7f)Nz: is not an instance of pymongo.operations.SearchIndexModel)r   r8   r   r?  )r  r  s    r]   r  ;AsyncCollection._create_search_indexes.<locals>.gen_indexes
  sB     !%)9::# )#]^  nn$  s   =A )createSearchIndexesr  r  )r~   r}   indexesCreatedr   r  )
r   rJ  r	  r   r=   CREATE_SEARCH_INDEXESr  r?   r  r2   )
r   r  r   r   r   r  r   r   respr  s
    `        r]   r  &AsyncCollection._create_search_indexes
  s       '9	% '+iiD<OP

6..s88 / 
 
 
 
 . 6 6<	 '  D 044D/EF/Ee&M/EF
 
 
 G
 
 
 
s~   AC,"C#C,+C,C,/(CC	C#C1C3C,?C C,C,	CCC,C)CC)%C,c           	     z  #    U R                   US.nUR                  U5        Ub  X5S'   U R                  U[        R                  S9I Sh  vN  ISh  vN nU R                  UU[        R                  SS/[        S9I Sh  vN   SSS5      ISh  vN   g NM NF N N! , ISh  vN  (       d  f       g= f7f)a  Delete a search index by index name.

:param name: The name of the search index to be deleted.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: optional arguments to the dropSearchIndexes
    command (like maxTimeMS) can be passed as keyword arguments.

.. note:: requires a MongoDB server version 7.0+ Atlas cluster.

.. versionadded:: 4.5
)dropSearchIndexr   Nr   r  r  r  r~   r   r}   )	r   r	  r   r=   DROP_SEARCH_INDEXESr  r?   r  r2   )r   r   r   r   r   r   r   s          r]   drop_search_index!AsyncCollection.drop_search_index
  s     * #'**d;

6$	N..w#BYBY.ZZZZ^b-- . 6 6"0"!5<      [ZZ [ZZZl   A	B;BB;BB;+B!BB!B;BB;B;B!B;!B8'B*(B84B;c           	     z  #    U R                   XS.nUR                  U5        Ub  XFS'   U R                  U[        R                  S9I Sh  vN  ISh  vN nU R                  UU[        R                  SS/[        S9I Sh  vN   SSS5      ISh  vN   g NM NF N N! , ISh  vN  (       d  f       g= f7f)aB  Update a search index by replacing the existing index definition with the provided definition.

:param name: The name of the search index to be updated.
:param definition: The new search index definition.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: optional arguments to the updateSearchIndexes
    command (like maxTimeMS) can be passed as keyword arguments.

.. note:: requires a MongoDB server version 7.0+ Atlas cluster.

.. versionadded:: 4.5
)updateSearchIndexr   
definitionNr   r  r  r  r&  )	r   r	  r   r=   UPDATE_SEARCH_INDEXr  r?   r  r2   )r   r   r-  r   r   r   r   r   s           r]   update_search_index#AsyncCollection.update_search_index
  s     . %)JJW

6$	N..w#BYBY.ZZZZ^b-- . 6 6"0"!5<      [ZZ [ZZZr*  c                  #    U R                   R                  R                  U R                   R                  U R                  U R
                  U R                  U R                  5      nUR                  USU R                  0US9I Sh  vN nSnU  Sh  vN nUn  U(       d  0 $ UR                  S0 5      nUc   eSU;   a  US	 U$  N? N4
 N17f)a  Get the options set on this collection.

Returns a dictionary of options and their values - see
:meth:`~pymongo.asynchronous.database.AsyncDatabase.create_collection` for more
information on the possible options. Returns an empty
dictionary if the collection has not been created yet.

:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.

.. versionchanged:: 3.6
   Added ``session`` parameter.
r   )r   rm  r   Nr   r   )r   r   r~  r   r}   r~   r   r   list_collectionsr   r   )r   r   r   r  r  r0  r:  r   s           r]   r   AsyncCollection.options  s     ( nn##00NN  
 ++VTZZ$8' , 
 
  	#FI**Y+"""w!#

	s6   BCC	CCC
C0C
CCc                  #    Ub  XxS'   U" U UUUUUSSS00S9n	U R                   R                  R                  U	R                  U	R	                  U5      UU	R
                  (       + [        R                  S9I S h  vN $  N7f)Nr   r  r  rO   )r   r  )r   r   r  r  r  r  r=   	AGGREGATE)
r   aggregation_commandr   cursor_classr   r  r  r   r   r   s
             r]   
_aggregateAsyncCollection._aggregate5  s       '9!!L!#45
 ^^**::NN##G,---mm ; 
 
 	
 
s   A8B:A?;Bc           	       #    U R                   R                  R                  USS9 ISh  vN nU R                  " [        U[
        4UUSLUUS.UD6I Sh  vN sSSS5      ISh  vN   $  NA N N	! , ISh  vN  (       d  f       g= f7f)a  Perform an aggregation using the aggregation framework on this
collection.

The :meth:`aggregate` method obeys the :attr:`read_preference` of this
:class:`AsyncCollection`, except when ``$out`` or ``$merge`` are used on
MongoDB <5.0, in which case
:attr:`~pymongo.read_preferences.ReadPreference.PRIMARY` is used.

.. note:: This method does not support the 'explain' option. Please
   use `PyMongoExplain <https://pypi.org/project/pymongoexplain/>`_
   instead. An example is included in the :ref:`aggregate-examples`
   documentation.

.. note:: The :attr:`~pymongo.asynchronous.collection.AsyncCollection.write_concern` of
   this collection is automatically applied to this operation.

:param pipeline: a list of aggregation pipeline stages
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param let: A dict of parameter names and values. Values must be
    constant or closed expressions that do not reference document
    fields. Parameters can then be accessed as variables in an
    aggregate expression context (e.g. ``"$$var"``). This option is
    only supported on MongoDB >= 5.0.
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: extra `aggregate command`_ parameters.

All optional `aggregate command`_ parameters should be passed as
keyword arguments to this method. Valid options include, but are not
limited to:

  - `allowDiskUse` (bool): Enables writing to temporary files. When set
    to True, aggregation stages can write data to the _tmp subdirectory
    of the --dbpath directory. The default is False.
  - `maxTimeMS` (int): The maximum amount of time to allow the operation
    to run in milliseconds.
  - `batchSize` (int): The maximum number of documents to return per
    batch. Ignored if the connected mongod or mongos does not support
    returning aggregate results using a cursor.
  - `collation` (optional): An instance of
    :class:`~pymongo.collation.Collation`.
  - `bypassDocumentValidation` (bool): If ``True``, allows the write to opt-out of document level validation.


:return: A :class:`~pymongo.asynchronous.command_cursor.AsyncCommandCursor` over the result
  set.

.. versionchanged:: 4.1
   Added ``comment`` parameter.
   Added ``let`` parameter.
   Support $merge and $out executing on secondaries according to the
   collection's :attr:`read_preference`.
.. versionchanged:: 4.0
   Removed the ``useCursor`` option.
.. versionchanged:: 3.9
   Apply this collection's read concern to pipelines containing the
   `$out` stage when connected to MongoDB >= 4.2.
   Added support for the ``$merge`` pipeline stage.
   Aggregations that write always use read preference
   :attr:`~pymongo.read_preferences.ReadPreference.PRIMARY`.
.. versionchanged:: 3.6
   Added the `session` parameter. Added the `maxAwaitTimeMS` option.
   Deprecated the `useCursor` option.
.. versionchanged:: 3.4
   Apply this collection's write concern automatically to this operation
   when connected to MongoDB >= 3.4. Support the `collation` option.
.. versionchanged:: 3.0
   The :meth:`aggregate` method always returns an AsyncCommandCursor. The
   pipeline argument must be a list.

.. seealso:: :doc:`/examples/aggregation`

.. _aggregate command:
    https://mongodb.com/docs/manual/reference/command/aggregate
FcloseN)r   r  r  r   )r   r   r   r8  r"   r&   )r   r   r   r  r   r   r   s          r]   r  AsyncCollection.aggregateU  s     h >>((55gU5KKq-"	 !(!4	 	 	 LKK	 LKKKsV   )BA-B(A3A/A3B'A1(B/A31B3B
9A<:B
Bc           
       #    U R                   R                  R                  (       a  [        S5      eUb  X4S'   U R                   R                  R	                  USS9 ISh  vN n[        [        [           U R                  " [        U[        4UUSLS.UD6I Sh  vN 5      sSSS5      ISh  vN   $  NT N N	! , ISh  vN  (       d  f       g= f7f)a  Perform an aggregation and retrieve batches of raw BSON.

Similar to the :meth:`aggregate` method but returns a
:class:`~pymongo.asynchronous.cursor.AsyncRawBatchCursor`.

This example demonstrates how to work with raw batches, but in practice
raw batches should be passed to an external library that can decode
BSON into another data type, rather than used with PyMongo's
:mod:`bson` module.

  >>> import bson
  >>> cursor = await db.test.aggregate_raw_batches([
  ...     {'$project': {'x': {'$multiply': [2, '$x']}}}])
  >>> async for batch in cursor:
  ...     print(bson.decode_all(batch))

.. note:: aggregate_raw_batches does not support auto encryption.

.. versionchanged:: 3.12
   Added session support.

.. versionadded:: 3.6
z6aggregate_raw_batches does not support auto encryptionNr   Fr;  )r   r  )r   r   r  r/   r   r   r)   rG   r8  r#   r'   )r   r   r   r   r   r   s         r]   aggregate_raw_batches%AsyncCollection.aggregate_raw_batches  s     > >>  ++"#[\\ '9>>((55gU5KKq#M2oo4. %,D%8  
 LKK LKKKsZ   A C"B7#C&7B=B9B=%C1B;2C9B=;C=CCCCc                  #    [        U[        5      (       d  [        S[        U5       35      eU(       a  SU;   a  [	        S5      eUS   S:X  d	  US   S:X  a  [	        S5      eSU;   a!  UR                  S	5      (       d  [	        S
5      eU R                  R                   SU 3nU R                  US.nUR                  U5        Ub  X5S'   U R                  XR5      nU R                  U[        R                  S9I Sh  vN  ISh  vN nU R                  R                  R                  U5       ISh  vN nUR!                  SUUSUU R                  R                  S9I Sh  vN sSSS5      ISh  vN   sSSS5      ISh  vN   $  N N NZ N, N N! , ISh  vN  (       d  f       O= fSSS5      ISh  vN    g! , ISh  vN  (       d  f       g= f7f)a  Rename this collection.

If operating in auth mode, client must be authorized as an
admin to perform this operation. Raises :class:`TypeError` if
`new_name` is not an instance of :class:`str`.
Raises :class:`~pymongo.errors.InvalidName`
if `new_name` is not a valid collection name.

:param new_name: new name for this collection
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: additional arguments to the rename command
    may be passed as keyword arguments to this helper method
    (i.e. ``dropTarget=True``)

.. note:: The :attr:`~pymongo.asynchronous.collection.AsyncCollection.write_concern` of
   this collection is automatically applied to this operation.

.. versionchanged:: 3.6
   Added ``session`` parameter.

.. versionchanged:: 3.4
   Apply this collection's write concern automatically to this operation
   when connected to MongoDB >= 3.4.

z)new_name must be an instance of str, not ro   rp   r   rs   rt   z/collection names must not start or end with '.'rq   rr   z%collection names must not contain '$')renameCollectiontoNr   r  adminT)r   r   r   r   )r   r   r   r   r.   r   r   r   r   r	  r   r   r=   RENAMEr   r   r   )	r   new_namer   r   r   r   r   r   r   s	            r]   renameAsyncCollection.rename  s    H (C((GXGWXYY48+@AAA;#"!4OPP(?8#6#6}#E#EEFFnn))*!H:6#'??(C

6$	N33CA..w#**.MMMMQU~~,,99'BBa!\\"/.2>>00 *   CBB NMMB C NBBB NMMMMMs   C=G?F GF	G*G6F7G:,F&F'F*G6F7G;GFGGGFGGF0	F" F0	,G3G>G?GGGGGc                  ^ ^^	#    [        U[        5      (       d  [        S[        U5       35      eT R                  US.mUb  SU;   a  [        S5      eX&S'   [        UR                  SS5      5      m	TR                  U5        Ub  UTS'   Ub0  [        U[        5      (       d  [        R                  " U5      nUTS'             SUU	U 4S	 jjnT R                  Xs[        R                  S
9I Sh  vN $  N7f)aU  Get a list of distinct values for `key` among all documents
in this collection.

Raises :class:`TypeError` if `key` is not an instance of
:class:`str`.

All optional distinct parameters should be passed as keyword arguments
to this method. Valid options include:

  - `maxTimeMS` (int): The maximum amount of time to allow the count
    command to run, in milliseconds.
  - `collation` (optional): An instance of
    :class:`~pymongo.collation.Collation`.

The :meth:`distinct` method obeys the :attr:`read_preference` of
this :class:`AsyncCollection`.

:param key: name of the field for which we want to get the distinct
    values
:param filter: A query document that specifies the documents
    from which to retrieve the distinct values.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param comment: A user-provided comment to attach to this
    command.
:param hint: 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.asynchronous.collection.AsyncCollection.create_index`
    (e.g. ``[('field', ASCENDING)]``).
:param kwargs: See list of options above.

.. versionchanged:: 4.12
   Added ``hint`` parameter.

.. versionchanged:: 3.6
   Added ``session`` parameter.

.. versionchanged:: 3.4
   Support the `collation` option.

z$key must be an instance of str, not )distinctr  Nqueryz can't pass both filter and queryr   r   rX  c           
     h   >#    TR                  UTUTR                  TU SS0S9I S h  vN S   $  N7f)NvaluesrO   )r~   r   r   r   r   )r  r   )r   r  r   r~   r   r   r   s       r]   r  &AsyncCollection.distinct.<locals>._cmdg  sQ      mm$3!%!2!2'#!)1 $   
 
s   %202r  )
r   r4  r  rc   r   rb   r~   r  r6  rJ  )r   r   r   r   r   r-   r*   r  r	  r    r_  r  r=   DISTINCT)
r   r  rm  r   r   rX  r   r  r   r   s
   `       @@r]   rJ  AsyncCollection.distinct%  s    d #s##B49+NOO::c2& ()KLL$7O.vzz+t/LM	

6$C	NdC((%55d;CK	1		 "	 3		
 	 	$ 44Tcll4[[[[s   C0C<5C:6C<c
                $  ^ ^^^^^#    [         R                  " SU5        [        U[        5      (       d  [	        S[        U5       35      e[        U
R                  SS5      5      mT R                  XS.mU	b  [         R                  " SU	5        U	TS'   TR                  U
5        Ub  [        R                  " US5      TS'   Ub  [        R                  " U5      TS	'   Ub  [        S
U5        UTS
'   Tb+  [        T[        5      (       d  [        R                  " T5      mT R                  TU5      m        SUUUUU U4S jjnT R                   R"                  R%                  TR&                  UU[(        R*                  S9I Sh  vN $  N7f)zInternal findAndModify helper.rm  zKreturn_document must be ReturnDocument.BEFORE or ReturnDocument.AFTER, not r   N)findAndModifyrK  newr  
projectionfieldsrZ  rP  c                  >#    T
R                   nTb   U(       d  [        S5      e[        T5      TS'   TbB  UR                  S:  a  [        S5      eU(       d  UR                  S:  a  [        S5      eTTS'   T	R	                  UT[
        R                  T
TU U[        S9I S h  vN n[        U5        UR                  S	5      $  N 7f)
NrU  rV  rW  zJMust be connected to MongoDB 4.2+ to use hint on find and modify commands.r  zYMust be connected to MongoDB 4.4+ to use hint on unacknowledged find and modify commands.rX  )r~   r   r   r   r   r   rN   )
r8  r-   rJ  r  r  r?   r  _FIND_AND_MODIFY_DOC_FIELDSr1   r   )r   r   r   r8  outrb  r   r   rX  r   r   s        r]   _find_and_modify_helperAAsyncCollection._find_and_modify.<locals>._find_and_modify_helper  s      )55L(#,P  '+=&9N#((1,,d  &$*?*?!*C,s  #F . 6 6+# /7 & 	 	C *#.777##	s   B C#C$!Cr  )r   r4  r   rb   r   r5  r6  r   )r   r  r   r5  r   r   r*   r  r   r	  r    _fields_list_to_dictr_  rL   r   r   r   r   r9  r8  r=   FIND_AND_MODIFY)r   rm  rT  rZ  rP  return_documentrb  rX  r   r  r   rY  r   r   r   s   `     ``    @@@r]   _find_and_modify AsyncCollection._find_and_modify{  s     	""8V4/400]^bcr^s]tu  /vzz+t/LM	 $

VT?&&uc2CJ

6!*??
LYCM(88>CKXv."CMdC((%55d;33CA 	$1 	$9H 	$[_ 	$ 	$  	$D ^^**;;&&#))	 < 
 
 	
 
s   FF	F
Fc                d   #    SUS'   Ub  XxS'   U R                   " XU4XdUS.UD6I Sh  vN $  N7f)a
  Finds a single document and deletes it, returning the document.

  >>> await db.test.count_documents({'x': 1})
  2
  >>> await db.test.find_one_and_delete({'x': 1})
  {'x': 1, '_id': ObjectId('54f4e12bfba5220aa4d6dee8')}
  >>> await db.test.count_documents({'x': 1})
  1

If multiple documents match *filter*, a *sort* can be applied.

  >>> async for doc in db.test.find({'x': 1}):
  ...     print(doc)
  ...
  {'x': 1, '_id': 0}
  {'x': 1, '_id': 1}
  {'x': 1, '_id': 2}
  >>> await db.test.find_one_and_delete(
  ...     {'x': 1}, sort=[('_id', pymongo.DESCENDING)])
  {'x': 1, '_id': 2}

The *projection* option can be used to limit the fields returned.

  >>> await db.test.find_one_and_delete({'x': 1}, projection={'_id': False})
  {'x': 1}

:param filter: A query that matches the document to delete.
:param projection: a list of field names that should be
    returned in the result document or a mapping specifying the fields
    to include or exclude. If `projection` is a list "_id" will
    always be returned. Use a mapping to exclude fields from
    the result (e.g. projection={'_id': False}).
:param sort: a list of (key, direction) pairs
    specifying the sort order for the query. If multiple documents
    match the query, they are sorted and the first is deleted.
:param hint: 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.asynchronous.collection.AsyncCollection.create_index`
    (e.g. ``[('field', ASCENDING)]``). This option is only supported
    on MongoDB 4.4 and above.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param let: Map of parameter names and values. Values must be
    constant or closed expressions that do not reference document
    fields. Parameters can then be accessed as variables in an
    aggregate expression context (e.g. "$$var").
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: additional command arguments can be passed
    as keyword arguments (for example maxTimeMS can be used with
    recent server versions).

.. versionchanged:: 4.1
   Added ``let`` parameter.
.. versionchanged:: 3.11
   Added ``hint`` parameter.
.. versionchanged:: 3.6
   Added ``session`` parameter.
.. versionchanged:: 3.2
   Respects write concern.

.. warning:: Starting in PyMongo 3.2, this command uses the
   :class:`~pymongo.write_concern.WriteConcern` of this
   :class:`~pymongo.asynchronous.collection.AsyncCollection` when connected to MongoDB >=
   3.2. Note that using an elevated write concern with this command may
   be slower compared to using the default write concern.

.. versionchanged:: 3.4
   Added the `collation` option.
.. versionadded:: 3.0
TremoveNr   r  rX  r   )r^  )	r   rm  rT  rZ  rX  r   r  r   r   s	            r]   find_one_and_delete#AsyncCollection.find_one_and_delete  sT     d  x '9**
*-'
MS
 
 	
 
s   '0.0c                   #    [         R                  " U5        X+S'   U
b  XS'   U R                  " UUUUU4U	UUS.UD6I Sh  vN $  N7f)a   Finds a single document and replaces it, returning either the
original or the replaced document.

The :meth:`find_one_and_replace` method differs from
:meth:`find_one_and_update` by replacing the document matched by
*filter*, rather than modifying the existing document.

  >>> async for doc in db.test.find({}):
  ...     print(doc)
  ...
  {'x': 1, '_id': 0}
  {'x': 1, '_id': 1}
  {'x': 1, '_id': 2}
  >>> await db.test.find_one_and_replace({'x': 1}, {'y': 1})
  {'x': 1, '_id': 0}
  >>> async for doc in db.test.find({}):
  ...     print(doc)
  ...
  {'y': 1, '_id': 0}
  {'x': 1, '_id': 1}
  {'x': 1, '_id': 2}

:param filter: A query that matches the document to replace.
:param replacement: The replacement document.
:param projection: A list of field names that should be
    returned in the result document or a mapping specifying the fields
    to include or exclude. If `projection` is a list "_id" will
    always be returned. Use a mapping to exclude fields from
    the result (e.g. projection={'_id': False}).
:param sort: a list of (key, direction) pairs
    specifying the sort order for the query. If multiple documents
    match the query, they are sorted and the first is replaced.
:param upsert: When ``True``, inserts a new document if no
    document matches the query. Defaults to ``False``.
:param return_document: If
    :attr:`ReturnDocument.BEFORE` (the default),
    returns the original document before it was replaced, or ``None``
    if no document matches. If
    :attr:`ReturnDocument.AFTER`, returns the replaced
    or inserted document.
:param hint: 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.asynchronous.collection.AsyncCollection.create_index` (e.g.
    ``[('field', ASCENDING)]``). This option is only supported on
    MongoDB 4.4 and above.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param let: Map of parameter names and values. Values must be
    constant or closed expressions that do not reference document
    fields. Parameters can then be accessed as variables in an
    aggregate expression context (e.g. "$$var").
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: additional command arguments can be passed
    as keyword arguments (for example maxTimeMS can be used with
    recent server versions).

.. versionchanged:: 4.1
   Added ``let`` parameter.
.. versionchanged:: 3.11
   Added the ``hint`` option.
.. versionchanged:: 3.6
   Added ``session`` parameter.
.. versionchanged:: 3.4
   Added the ``collation`` option.
.. versionchanged:: 3.2
   Respects write concern.

.. warning:: Starting in PyMongo 3.2, this command uses the
   :class:`~pymongo.write_concern.WriteConcern` of this
   :class:`~pymongo.asynchronous.collection.AsyncCollection` when connected to MongoDB >=
   3.2. Note that using an elevated write concern with this command may
   be slower compared to using the default write concern.

.. versionadded:: 3.0
r	  Nr   rb  )r   rn  r^  )r   rm  rp  rT  rZ  rP  r]  rX  r   r  r   r   s               r]   find_one_and_replace$AsyncCollection.find_one_and_replace#  sr     v 	&&{3&x '9**

 

 

 

 
	
 

s   A A	AA	c                   #    [         R                  " U5        [         R                  " SU5        X,S'   Ub  XS'   U R                  " UUUUUU4UU
U	S.UD6I Sh  vN $  N7f)a  Finds a single document and updates it, returning either the
original or the updated document.

  >>> await db.test.find_one_and_update(
  ...    {'_id': 665}, {'$inc': {'count': 1}, '$set': {'done': True}})
  {'_id': 665, 'done': False, 'count': 25}}

Returns ``None`` if no document matches the filter.

  >>> await db.test.find_one_and_update(
  ...    {'_exists': False}, {'$inc': {'count': 1}})

When the filter matches, by default :meth:`find_one_and_update`
returns the original version of the document before the update was
applied. To return the updated (or inserted in the case of
*upsert*) version of the document instead, use the *return_document*
option.

  >>> from pymongo import ReturnDocument
  >>> await db.example.find_one_and_update(
  ...     {'_id': 'userid'},
  ...     {'$inc': {'seq': 1}},
  ...     return_document=ReturnDocument.AFTER)
  {'_id': 'userid', 'seq': 1}

You can limit the fields returned with the *projection* option.

  >>> await db.example.find_one_and_update(
  ...     {'_id': 'userid'},
  ...     {'$inc': {'seq': 1}},
  ...     projection={'seq': True, '_id': False},
  ...     return_document=ReturnDocument.AFTER)
  {'seq': 2}

The *upsert* option can be used to create the document if it doesn't
already exist.

  >>> (await db.example.delete_many({})).deleted_count
  1
  >>> await db.example.find_one_and_update(
  ...     {'_id': 'userid'},
  ...     {'$inc': {'seq': 1}},
  ...     projection={'seq': True, '_id': False},
  ...     upsert=True,
  ...     return_document=ReturnDocument.AFTER)
  {'seq': 1}

If multiple documents match *filter*, a *sort* can be applied.

  >>> async for doc in db.test.find({'done': True}):
  ...     print(doc)
  ...
  {'_id': 665, 'done': True, 'result': {'count': 26}}
  {'_id': 701, 'done': True, 'result': {'count': 17}}
  >>> await db.test.find_one_and_update(
  ...     {'done': True},
  ...     {'$set': {'final': True}},
  ...     sort=[('_id', pymongo.DESCENDING)])
  {'_id': 701, 'done': True, 'result': {'count': 17}}

:param filter: A query that matches the document to update.
:param update: The update operations to apply.
:param projection: A list of field names that should be
    returned in the result document or a mapping specifying the fields
    to include or exclude. If `projection` is a list "_id" will
    always be returned. Use a dict to exclude fields from
    the result (e.g. projection={'_id': False}).
:param sort: a list of (key, direction) pairs
    specifying the sort order for the query. If multiple documents
    match the query, they are sorted and the first is updated.
:param upsert: When ``True``, inserts a new document if no
    document matches the query. Defaults to ``False``.
:param return_document: If
    :attr:`ReturnDocument.BEFORE` (the default),
    returns the original document before it was updated. If
    :attr:`ReturnDocument.AFTER`, returns the updated
    or inserted document.
:param array_filters: A list of filters specifying which
    array elements an update should apply.
:param hint: 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.asynchronous.collection.AsyncCollection.create_index` (e.g.
    ``[('field', ASCENDING)]``). This option is only supported on
    MongoDB 4.4 and above.
:param session: a
    :class:`~pymongo.asynchronous.client_session.AsyncClientSession`.
:param let: Map of parameter names and values. Values must be
    constant or closed expressions that do not reference document
    fields. Parameters can then be accessed as variables in an
    aggregate expression context (e.g. "$$var").
:param comment: A user-provided comment to attach to this
    command.
:param kwargs: additional command arguments can be passed
    as keyword arguments (for example maxTimeMS can be used with
    recent server versions).

.. 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`` and ``session`` options.
.. versionchanged:: 3.4
   Added the ``collation`` option.
.. versionchanged:: 3.2
   Respects write concern.

.. warning:: Starting in PyMongo 3.2, this command uses the
   :class:`~pymongo.write_concern.WriteConcern` of this
   :class:`~pymongo.asynchronous.collection.AsyncCollection` when connected to MongoDB >=
   3.2. Note that using an elevated write concern with this command may
   be slower compared to using the default write concern.

.. versionadded:: 3.0
rb  r	  Nr   )rX  r  r   )r   ru  rv  r^  )r   rm  r	  rT  rZ  rP  r]  rb  rX  r   r  r   r   s                r]   find_one_and_update#AsyncCollection.find_one_and_update  s     F 	%%f-$$_mD!x '9**
 
 
 
 	
 
s   AA!AA!)r   r   r   r   r   )FNNNNN)r   AsyncDatabase[_DocumentType]r   r   r   Optional[bool]r}   z(Optional[CodecOptions[_DocumentTypeArg]]r~   r  r   Optional[WriteConcern]r   Optional[ReadConcern]r   r4  r   r   r6  r7  )r   r   r6  AsyncCollection[_DocumentType])r6  r   )r   r   r6  r5  )r6  r  )r6  r   )r6  rk  )N...)
r}   r7  r~   r  r   rm  r   rn  r6  ro  )...)
r}   z#bson.CodecOptions[_DocumentTypeArg]r~   r  r   rm  r   rn  r6  z!AsyncCollection[_DocumentTypeArg])NNNN)
r}   z-Optional[bson.CodecOptions[_DocumentTypeArg]]r~   r  r   rm  r   rn  r6  zBAsyncCollection[_DocumentType] | AsyncCollection[_DocumentTypeArg])r   r  r   r4  r6  rK   )r   r   r   r   r6  r   )NNNNNNNNNNNN)r   zOptional[_Pipeline]r   Optional[str]r   ri  r   Optional[int]r   rq  r   Optional[_CollationIn]r   zOptional[Timestamp]r   r4  r   ri  r   Optional[Any]r   rp  r   rl  r6  z*AsyncCollectionChangeStream[_DocumentType])r   r4  r   r   r6  z$AsyncContextManager[AsyncConnection])
NNTNNNNNFN)r   rb   r   MutableMapping[str, Any]r~   r  r}   zOptional[CodecOptions]r   r5  r   z#Optional[Sequence[Union[str, int]]]r   rn  r   rm  r   rr  r   r4  r   r5  r   rs  r6  r  )NF)r   r   r   rt  r   rr  r   r4  r  ri  r  r5  r6  r7  )r   rt  r   r4  r6  r7  )TNNNN)r  z!Sequence[_WriteOp[_DocumentType]]r#  r5  r$  rl  r   r4  r   rs  r  Optional[Mapping]r6  rA   r   )r:  r  r#  r5  r   rK   r;  rq  r1  rl  r   r4  r   rs  r6  r   )NNN)
r?  z%Union[_DocumentType, RawBSONDocument]r$  rl  r   r4  r   rs  r6  rD   )TNNN)r,  z/Iterable[Union[_DocumentType, RawBSONDocument]]r#  r5  r$  rl  r   r4  r   rs  r6  rC   )FFNNTNNNNNFNNN)$r   rb   ra  r  r?  #Union[Mapping[str, Any], _Pipeline]rP  r5  rS  r5  r   rm  r;  rq  r#  r5  r1  rl  r   rr  rb  %Optional[Sequence[Mapping[str, Any]]]rX  Optional[_IndexKeyHint]r   r4  r   r5  r  ri  rZ  ri  r   rs  r6  ri  )FFNNTNNNNNNNN)"ra  r  r?  rv  r   r   rP  r5  rS  r5  r   rm  r;  rq  r#  r5  r1  rl  r   rr  rb  rw  rX  rx  r   r4  r  ri  rZ  ri  r   rs  r6  ri  )FNNNNNNN)rm  r  rp  r  rP  r5  r$  rl  r   rr  rX  rx  r   r4  r  ri  rZ  ri  r   rs  r6  rE   )	FNNNNNNNN)rm  r  r	  rv  rP  r5  r$  rl  r   rr  rb  rw  rX  rx  r   r4  r  ri  rZ  ri  r   rs  r6  rE   )rm  r  r	  rv  rP  r5  rb  rw  r$  rl  r   rr  rX  rx  r   r4  r  ri  r   rs  r6  rE   )r   r4  r   rs  r  ri  r6  r7  )	NNTNNNFNN)r   rb   ra  r  rS  r5  r   rm  r;  rq  r#  r5  r   rr  rX  rx  r   r4  r   r5  r  ri  r   rs  r6  r  )NNTNNNNN)ra  r  rS  r5  r   rm  r;  rq  r#  r5  r   rr  rX  rx  r   r4  r  ri  r   rs  r6  r  )NNNNN)rm  r  r   rr  rX  rx  r   r4  r  ri  r   rs  r6  rB   )rm  rs  r   r   r   r   r6  zOptional[_DocumentType])r   r   r   r   r6  zAsyncCursor[_DocumentType])r   r   r   r   r6  "AsyncRawBatchCursor[_DocumentType])r   r4  r   rb   r~   r  r   dict[str, Any]r   zOptional[Collation]r6  r  )r   rb   r~   r  r   rz  r   rr  r   r4  r6  ri  )r   rs  r   r   r6  r  )NN)
rm  r  r   r4  r   rs  r   r   r6  r  )r  zpCallable[[Optional[AsyncClientSession], Server, AsyncConnection, Optional[_ServerMode]], Coroutine[Any, Any, T]]r   r4  r   r   r6  rM   )
r  Sequence[IndexModel]r   r4  r   rs  r   r   r6  	list[str])r  r{  r   r4  r   r   r6  r|  )
r  r;   r   r4  r   rs  r   r   r6  r   )r   r4  r   rs  r   r   r6  r7  )
r  r;   r   r4  r   rs  r   r   r6  r7  )r   r4  r   rs  r6  r   )r   r4  r   rs  r6  rt  )
r   rp  r   r4  r   rs  r   r   r6  z%AsyncCommandCursor[Mapping[str, Any]])
r  z*Union[Mapping[str, Any], SearchIndexModel]r   r4  r   r   r   r   r6  r   )
r  zlist[SearchIndexModel]r   r4  r   rs  r   r   r6  r|  )
r   r   r   r4  r   rs  r   r   r6  r7  )r   r   r-  r  r   r4  r   rs  r   r   r6  r7  )r6  zType[_AggregationCommand]r   rI   r7  zType[AsyncCommandCursor]r   r4  r  r5  r  ri  r   rs  r   r   r6  !AsyncCommandCursor[_DocumentType])r   rI   r   r4  r  ri  r   rs  r   r   r6  r}  )
r   rI   r   r4  r   rs  r   r   r6  ry  )
rF  r   r   r4  r   rs  r   r   r6  rt  )r  r   rm  ri  r   r4  r   rs  rX  rx  r   r   r6  rJ  )rm  r  rT  1Optional[Union[Mapping[str, Any], Iterable[str]]]rZ  Optional[_IndexList]rP  rl  r]  r5  rb  rw  rX  rx  r   r4  r  ru  r   r   r6  r   )NNNNNN)rm  r  rT  r~  rZ  r  rX  rx  r   r4  r  ri  r   rs  r   r   r6  rG   )rm  r  rp  r  rT  r~  rZ  r  rP  r5  r]  r5  rX  rx  r   r4  r  ri  r   rs  r   r   r6  rG   )rm  r  r	  rv  rT  r~  rZ  r  rP  r5  r]  r5  rb  rw  rX  rx  r   r4  r  ri  r   rs  r   r   r6  rG   )RrT   rU   rV   rW   rX   r|   r   r   r   r   r   r   r   propertyr   r   r   r   r   r   __iter__r   nextr   r   r   r  r  r   r   applyr(  r<  rA  rL  rd  rj  rq  rw  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   r8  r  r?  rG  rJ  rQ   rY   r^  rc  rf  ri  r[   __classcell__)r   s   @r]   rg   rg      s   + "'BF1504.204~.~ ~ 	~
 @~ /~ .~ ,~ .~ ~ 
~ ~@&	
L
!2
        #1403.1 / .	
 , 
(   2503.1: / .	
 , 
+  HL1504.2+
D+
 /+
 .	+

 ,+
 
L+
Z4$4/K4	4 HD D
" )-'+48+/$(,07;0437!%59/3K%K %K 2	K
 )K "K *K "5K .K 1K K &3K -K 
4KZP3P@CP	-P 2604@D.204,004 %%)88 *8 /	8
 .8 8 >8 ,8 .8 *8 .8 8 #8 
8@ 9=#!! *! *	!
 .! 6! ! 
!FO)O .O 
	O6 [[ 5904!%!%_*3_* _* %3	_*
 ._* _* _* 
_* _*R "&)) ) $	)
 ) ') .) ) 
)\ 6:04!%>
7>
 %3>
 .	>

 >
 
>
@ [[ 5904!%HJBHJ HJ %3	HJ
 .HJ HJ 
HJ HJ^ 04#)-,0?C(,04 %+/,0!%%^^ $^ 6	^
 ^ ^ .^ ^ ^ '^ *^ =^ &^ .^ ^  )!^" *#^$ %^& 
%'^J 04#)-,0?C(,04+/,0!%#1
#1
 61
 	1

 1
 1
 .1
 1
 1
 '1
 *1
 =1
 &1
 .1
 )1
  *!1
" #1
$ 
%%1
n 59,0(,04+/,0!%k
!k
 'k
 	k

 %3k
 *k
 &k
 .k
 )k
 *k
 k
 
k
b 59,0?C(,04+/,0!%v
!v
 4v
 	v

 %3v
 *v
 =v
 &v
 .v
 )v
 *v
 v
 
v
x ?C59,0(,04+/!%c
!c
 4c
 	c

 =c
 %3c
 *c
 &c
 .c
 )c
 c
 
c
N 15!%8<	)
-)
 )
 6	)

 
)
` 15#,0(,04 %+/!%66 $6 	6
 .6 6 6 *6 &6 .6 6 )6 6 
6x 15#,0(,04+/!%&
#&
 &
 .	&

 &
 &
 *&
 &&
 .&
 )&
 &
 
&
V -1(,04+/!%?
!?
 *?
 &	?

 .?
 )?
 ?
 
?
H -1(,04+/!%?
!?
 *?
 &	?

 .?
 )?
 ?
 
?
D '+!#!36!BE!	 !Fz2x:>-  /	
  ' 
(++ /+ 	+
 *+ .+ 
%+2*V^ 15!%	YO!YO .YO 	YO
 YO 
YOvb
b .b b 
b" 15!%	-F%-F .-F 	-F
 -F 
-F^ [[*+*6R*^a*	* *^ 15!%	tPtP .tP 	tP
 tP 
tPp 15!%?-? ? 	?
 
?B [[ 15!%	.J$.J ..J 	.J
 .J 
.J .J` [[ 15!%	$ . 	
  
 < 15!%:-: : 
6	:> 15!%/-/ / 
6	/f 15!%(-( ( 
"	(X #04!%	3
3
 .3
 	3

 3
 
/3
p 15	[9[ .[ 	[
 [ 
[B 15!%	U&U .U 	U
 U 
U6 15!%	G&G .G 	G
 G 
GF 15!%	   .  	 
   
 L 15!%"" &" .	"
 " " 
"L 15!%,-, , 
"	,\ [[ ,0!%
6
 
 /	

 .
 
 )
 
 
 
+
 
D 15+/!%^^ .^ )	^
 ^ ^ 
+^F 15!%	.. .. 	.
 . 
,.` [[ 15!%	== .= 	=
 = 
"= =D /304!%(,T\T\ ,T\ .	T\
 T\ &T\ T\ 
T\v "& . 5 5?C(,04!%M
!M
 FM
 #	M

 M
 M
 =M
 &M
 .M
 M
 M
 
M
d IM%)(,04+/!%W
!W
 FW
 #	W

 &W
 .W
 )W
 W
 W
 
W
z IM%) . 5 5(,04+/!%i
!i
 'i
 F	i

 #i
 i
 i
 &i
 .i
 )i
 i
 i
 
i
^ IM%) . 5 5?C(,04+/!%S
!S
 4S
 F	S

 #S
 S
 S
 =S
 &S
 .S
 )S
 S
 S
 
S
 S
r\   rg   )xrX   
__future__r   r   collectionsr   typingr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   bson.codec_optionsr   r   bson.objectidr   bson.raw_bsonr   bson.sonr   bson.timestampr   pymongor   r   r   r    r!    pymongo.asynchronous.aggregationr"   r#   pymongo.asynchronous.bulkr$   "pymongo.asynchronous.change_streamr%   #pymongo.asynchronous.command_cursorr&   r'   pymongo.asynchronous.cursorr(   r)   pymongo.collationr*   pymongo.commonr+   r,   pymongo.errorsr-   r.   r/   r0   pymongo.helpers_sharedr1   pymongo.messager2   pymongo.operationsr3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   pymongo.read_concernr>   pymongo.read_preferencesr?   r@   pymongo.resultsrA   rB   rC   rD   rE   pymongo.typingsrF   rG   rH   rI   pymongo.write_concernrJ   rK   rL   r   rM   rW  _WriteOprQ   bsonr^   #pymongo.asynchronous.client_sessionr_   r   ra   pymongo.asynchronous.poolrb   pymongo.asynchronous.serverrc   rd   re   
BaseObjectrg   rS   r\   r]   <module>r     s2   , "      * C " )  $ E E 1 J 9 :  A :    6 @  U T W WCL&l  m}< < DF;92+0W6
f'')? W6
r\   