+\hmEdZddlmZddlZddlmZddlmZmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZddlmZmZddlmZddlmZdd l m!Z!dd l"m#Z#dd l$m%Z%m&Z&m'Z'm(Z(m)Z)dd l*m+Z+m,Z,dd l-m.Z.ddl/m0Z0ddl1m2Z2m3Z3ddl4m5Z5m6Z6ddl7m8Z8ddl9m:Z:m;Z;ddlZ>m?Z?m@Z@ddlAmBZBddlCmDZDddlEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPddlQmRZRddlSmTZTmUZUddlVmWZWmXZXmYZYmZZZm[Z[ddl\m]Z]m^Z^m_Z_m`Z`ddlambZbmcZcmdZddZeedZfddiZgeeIe^eGeFeJe^eMeLfZhGd d!Zier.ddljZjdd"l*mkZkdd#llmmZmdd$lnmoZodd%lpmqZqdd&lrmsZsdd'l7mtZtdd(lQmuZuGd)d*e'je e^Zwy)+z%Collection level utilities for Mongo.) annotationsN)abc) TYPE_CHECKINGAnyAsyncContextManagerCallable CoroutineGenericIterableIteratorMappingMutableMappingNoReturnOptionalSequenceTypeTypeVarUnioncastoverload)DEFAULT_CODEC_OPTIONS CodecOptions)ObjectId)RawBSONDocument)SON) Timestamp) ASCENDING_csotcommonhelpers_sharedmessage)_CollectionAggregationCommand _CollectionRawAggregationCommand) _AsyncBulk)AsyncCollectionChangeStream)AsyncCommandCursorAsyncRawBatchCommandCursor) AsyncCursorAsyncRawBatchCursor)validate_collation_or_none)_ecoc_coll_name_esc_coll_name)ConfigurationError InvalidNameInvalidOperationOperationFailure)_check_write_command_response)_UNICODE_REPLACE_CODEC_OPTIONS) DeleteMany DeleteOne IndexModel InsertOne ReplaceOneSearchIndexModel UpdateMany UpdateOne _IndexKeyHint _IndexList_Op)DEFAULT_READ_CONCERN)ReadPreference _ServerMode)BulkWriteResult DeleteResultInsertManyResultInsertOneResult UpdateResult) _CollationIn _DocumentType_DocumentTypeArg _Pipeline)DEFAULT_WRITE_CONCERN WriteConcernvalidate_booleanFTvalueceZdZdZdZ dZy)ReturnDocumentzAn enum used with :meth:`~pymongo.asynchronous.collection.AsyncCollection.find_one_and_replace` and :meth:`~pymongo.asynchronous.collection.AsyncCollection.find_one_and_update`. FTN)__name__ __module__ __qualname____doc__BEFOREAFTERb/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pymongo/asynchronous/collection.pyrQrQqs F E;rYrQ)_AggregationCommand)AsyncClientSession AsyncDatabase)AsyncConnection)Server) Collation) ReadConcernc  eZdZdZ dI dJfd ZdKdZdKdZdLdZdMdZdMd Z dNd Z dOd Z e dLd Z e dLd Ze dPdZe dQ dRdZe dS dTdZ dU dVdZ dWdZdZdOdZeZdXdZ dY dZdZ d[dZ d\ d]dZ d^ d_dZ d`dZej: da dbdZ dc dddZ de dfdZ ej: dg dhdZ! di djdZ" dk dldZ# dm dnd Z$ do dpd!Z% dm dqd"Z& de drd#Z' ds dtd$Z( du dvd%Z) dw dxd&Z* dw dxd'Z+ dc dyd(Z,dzd)Z-d{d*Z. d|d+Z/ d}d,Z0dcd~d-Z1 d dd.Z2 dd/Z3 d dd0Z4ej: dd1Z5 d dd2Z6 d dd3Z7ej: d dd4Z8ej: d dd5Z9 d dd6Z: d dd7Z; d dd8Z< de dd9Z= d dd:Z> d dd;Z? d dd<Z@ d dd=ZA d dd>ZB d dd?ZCej: d dd@ZD de ddAZE d ddBZFej: d ddCZG dU ddDZHdeIjddddf ddEZK d ddFZLdddeIjddddf ddGZMdddeIjdddddf ddHZNxZOS)AsyncCollectionz!An asynchronous Mongo collection.FNc  t ||xs |j|xs |j|xs |j|xs |j t |tstdt|ddl m } t || sFtdt|jDs!tdt|j|rd|vr tdd|vr|j!d std |z|dd k(s|d d k(rtd |zd|vr td||_||_|j"j&d |j$|_|jj+dt,|_|j0j2j4|_|s| r@t8r/t;j<dt>d|jA| |ytCdy)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 `_. z%name must be an instance of str, not rr]c3:K|]}|jdk(yw)r^N)rR).0clss rZ z+AsyncCollection.__init__..sY3s||6Ysz!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 '.': %rz4collection names must not contain the null characterreplace)unicode_decode_error_handlerdocument_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_optionsread_preference write_concern read_concern isinstancestr TypeErrortypepymongo.asynchronous.databaser^any__mro__rRr. startswith _database_namename _full_name_replacedict_write_response_codec_optionsclientoptionstimeout_timeout_IS_SYNCwarningswarnDeprecationWarning_create ValueError) selfdatabasercreaterxryrzr{sessionkwargsr^ __class__s rZrwzAsyncCollection.__init__sf   3X33  7x77  3X33  1H11  $$CDJ<PQ Q?(M2Y$x.BXBXYY"CDND[D[C\ ]^^tt|@A A $;0G HIDPQ Q 7c>T"X_SVZZ[ [ T>TU U7? !^^0014::,?-1-?-?-H-H)24.I. *!//77 V ~&   VW- ZrYc |jdr;|jd|}tt|jd|d|d|d|j |S)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 _rnz has no attribute z. To access the z collection, use database['z'].)rrAttributeErrorrrR __getitem__)rr full_names rZ __getattr__zAsyncCollection.__getattr__ sr ??3 ::,av.I :&&''9$AQR[Q\-i[= %%rYc t|j|jd|d|j|j|j |j S)NrnFrdrrrxryrzr{)rrs rZrzAsyncCollection.__getitem__sO NNzzl!D6 "             rYcft|jd|jd|jdS)N(z, ))rrRrrrs rZ__repr__zAsyncCollection.__repr__'s/t*%%&a'9DJJ>KKrYct|tr4|j|jk(xr|j|j k(St SN)r|rdrrrrNotImplementedrothers rZ__eq__zAsyncCollection.__eq__*s7 e_ ->>U^^3P ejj8P PrYc||k( SrrXrs rZ__ne__zAsyncCollection.__ne__/s5=  rYcDt|j|jfSr)hashrrrs rZ__hash__zAsyncCollection.__hash__2sT^^TZZ011rYcDtt|jd)Nzq objects do not implement truth value testing or bool(). Please compare with None instead: collection is not None)NotImplementedErrorrrRrs rZ__bool__zAsyncCollection.__bool__5s)!Dz""#$8 8  rYc|jS)zThe full name of this :class:`AsyncCollection`. The full name is of the form `database_name.collection_name`. )rrs rZrzAsyncCollection.full_name<s rYc|jS)z*The name of this :class:`AsyncCollection`.)rrs rZrzAsyncCollection.nameDszzrYc|jS)z{The :class:`~pymongo.asynchronous.database.AsyncDatabase` that this :class:`AsyncCollection` is a part of. )rrs rZrzAsyncCollection.databaseIs ~~rYcyrrXrrxryrzr{s rZ with_optionszAsyncCollection.with_optionsP rYcyrrXrs rZrzAsyncCollection.with_optionsZrrYc t|j|jd|xs |j|xs |j|xs |j |xs |j S)aGet 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. Frrs rZrzAsyncCollection.with_optionsds[F NN JJ   /T//  3t33  /T//  -D--  rYc`|jd}| tdi|S|j|S)N writeConcernrX)getrK_write_concern_for)rcmdrraw_wcs rZ_write_concern_for_cmdz&AsyncCollection._write_concern_for_cmds7(  )&) )**73 3rYctd)Nz('AsyncCollection' object is not iterable)r~rs rZ__next__zAsyncCollection.__next__sBCCrYc*d|jvr/tdt|jd|jztdt|jdt|jd|jj ddz)zAThis is only here so that some API misusages are easier to debug.rn'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.ro)rr~rrRsplitrargsrs rZ__call__zAsyncCollection.__call__s djj DJ''()!JJ'  T ##$%**.t**=*=)>?5 57;zz7G7G7LR7P Q  rYc pKt|||||||||| | | | } | jd{| S7w)aXWatch 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 `_. .. _change streams specification: https://github.com/mongodb/specifications/blob/master/source/change-streams/change-streams.md N)r%_initialize_cursor)rpipeline full_document resume_aftermax_await_time_ms batch_size collationstart_at_operation_timer start_aftercommentfull_document_before_changeshow_expanded_events change_streams rZwatchzAsyncCollection.watchsYt4        #    '  ..000 1s +646cjK|jjj||d{S7wr)rr_conn_for_writes)rr operations rZrz AsyncCollection._conn_for_writes>s+^^**;;GYOOOOs *313c K|jjj| 4d{} |j|jj||xs|j | |xs |j ||||d| | |jj| | d{cdddd{S777 #1d{7swYyxYww)aInternal 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{rzparse_write_concern_errorrrrretryable_write user_fields)rr _tmp_sessioncommandr_read_preference_forrx)rconnrryrxcheckallowable_errorsr{rzrrrrss rZ_commandzAsyncCollection._commandCsP>>((55g>  !##E4#<#C ?C C c Kd|i}|r||d<|r&d|vrt|d|d<|j||j|tjd{4d{}|r(|j dkrt d|j d|j||tj|j||| d{dddd{y77}77 #1d{7swYyxYww) z.Sends a create command with the given options.rencryptedFieldssizerNzDriver support of Queryable Encryption is incompatible with server. Upgrade server to use Queryable Encryption. Got maxWireVersion z. but need maxWireVersion >= 21 (MongoDB >=7.0))ryrzrr) floatupdaterr=CREATEmax_wire_versionr-rr?PRIMARYr) rrrrrencrypted_fields qev2_requiredrrs rZ_create_helperzAsyncCollection._create_helper}s (. %5C! "  "'"8 JJw ..w#**.MM  QU!6!6!;(**.*?*?)@@np -- . 6 6"55g>#       M      smAC<CC<#C!$C<'A"C' C# C' C<C%C<!C<#C'%C<'C9-C0 .C95C<c`Kt|jdd}|jdd}|rtjd|dddiddi}|j t ||j |d|d d{|j t||j |d|d{|j |j |||| d{|jd tfg|d{y|j |j |||d{y77w7Q727 w) NrrrclusteredIndex_idrOT)keyunique)r)r__safeContent__) r*poprvalidate_is_mappingrr,rr+ create_indexr)rrrrroptss rZrzAsyncCollection._createsH /w{{;/MN ";;'8$?   & &'9;K L$uajD&IJD%%/<" &  %% 0$**=tT7  %% GYJZ&  ##&7%C$DgN N N%%djj'9gN N N    O NsZAD$?/D..D&/'D.D( D.7D*8&D.D,D.&D.(D.*D.,D.clKtjd|t|||||}|D]} |j||j |} |j| |tjd{} | t| dStidS#t$rt |ddwxYw7:w)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)rletz is not a valid requestNTF) r validate_listr$ _add_to_bulkrr~rexecuter=INSERTrA) rrorderedbypass_document_validationrrrblkrequestrzbulk_api_results rZ bulk_writezAsyncCollection.bulk_writesf Z2w(BGY\] QG Q$$S) Q //8 # M7CJJ OO  &"?D9 9r5))" Q7+-D EFDP QPs(,B4B7B47B28B4B//B4cb Kxs jj}j||gd || d< d fd } jjj || |t jd{t|ts|jdSy7&w)z0Internal helper for inserting a single document.)insertr  documentsNrc Kd<|jjjj|jj|d{}t |y7w)NbypassDocumentValidationrzrxrrr)rrrrrr1)rrrresultbypass_doc_valrrrzs rZ_insert_commandz4AsyncCollection._insert_one.._insert_command.sp)6D23<<##+"@@~~,, /(F *& 1sAA+A)A+rr)rOptional[AsyncClientSession]rr_rboolreturnNone) rz acknowledgedrrr_retryable_writer=r r|rr) rdocr rzop_idrrrrrrs ` ` ` @rZ _insert_onezAsyncCollection._insert_ones&;);); $11 !YY7#O  !(GI  21 29H 2[_ 2  2 2$nn##44 /7cjj5   #/775> !  sBB/B-'B/c Ktjd|t|tsd|vs t |d<|j |}t |j|d|d|||d{|jS7w)aZInsert 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 documentrTN)r rzr rrr) rvalidate_is_document_typer|rrrrDr!r)rr#r rrrzs rZ insert_onezAsyncCollection.insert_oneHs\ ((X>8_5(9J&jHUO//8 ""+9#   & &   sA)B+A?,Bc Kttjrttjss t dg d fd }|j |}t ||||}t||_|j||tjd{t |jS7w)abInsert 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 listc3KD]a}tjd|t|ts%d|vr t |d<j |dt j|fcyw)z6A generator that validates documents and handles _ids.r#rN)rr$r|rrappendr!_INSERT)r#r inserted_idss rZgenz(AsyncCollection.insert_many..gensd% 200XF!(O<H,*2* ''811  2sA(A+)rN)rz'Iterator[tuple[int, Mapping[str, Any]]])r|rr r r~rr$listopsrr=r rCr) rrr r rrr+rzr r*s ` @rZ insert_manyzAsyncCollection.insert_manysh9cll3)S[[1@A A')  2//8 w(BGTsu+kk-#**=== m.H.HII >sB$C(C)Cc Ktd|t| } |xs |j}|j}||||d}| |s t d| |d<| |s t d| |d<| F|s|j dkr t d t | tstj| } | |d <|7|s|j d kr t d tjd |||d <|j||gd}|tjd|||d<|||d<| | |d<|j|jj|||j| |jj |d{j#}t%||j'dr d|vrd|d<nd|d<d|vr|ddd|d<|sy|S7Tw)!Internal update / replace helper.upsert)qumultir1N3Collation is unsupported for unacknowledged writes.r6arrayFilters is unsupported for unacknowledged writes. arrayFilterszPMust be connected to MongoDB 4.2+ to use hint on unacknowledged update commands.hintzPMust be connected to MongoDB 8.0+ to use sort on unacknowledged update commands.sort)rr updatesrrrrnupsertedTupdatedExistingFrr)rLr*rzrr-rr|r}r _index_documentrrrrrrrcopyr1r)rrcriteriar#r1r4rzr r rr array_filtersr9rrrr;rr update_docrrs rZ_updatezAsyncCollection._updates#* 6*.y9 %;);); $11  &  ()^__*3 ;'  $()abb-: >*  D$9$9A$=(fdC(%55d;!%Jv   D$9$9B$>(f  & &vt 4!%Jv !YY7 |T ?  & &uc 2 GEN  !(GI   %2@G. / ,,##+"@@~~,, /  $&  &f- ::c?z7(,F$ %(-F$ %V#%+J%7%:5%Az" / sE-G/G0AGc K d  fd }jjjxs jjxr || |d{S7w)r0cdKj|   || d{S7w)N)r1r4rzr r rrrCr9rrrr;r)rE)rrrrCrrrrBr#r9rr4r r rr;r1rzs rZrEz2AsyncCollection._update_retryable.._updateHs\+-#+ /#& s &0.0N)rrrr_rrrOptional[Mapping[str, Any]])rrrrzr)rrBr#rr1r4rzr r rrrCr9rrr;rrEs``` ````````` ``` rZ_update_retryablez!AsyncCollection._update_retryable3s* 1 9H [_  (   .^^**;;  0d00 > > Lu9        sA%A=6A;7A=c DKtjd|tj||tjd||j|} t |j ||t j|| |||||| |  d{| jS7w)aE 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)rzrrr9rrr;r) rrvalidate_ok_for_replacerrErIr=UPDATEr) rrK replacementr1r rr9rrr;rrzs rZ replace_onezAsyncCollection.replace_onefsl ""8V4&&{3 ?  & &uc 2//8 (( +9#)    & &   sBB  B B c BKtjd|tj|tjd||j |} t |j ||tj|| |||||| | |  d{| jS7w)a 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 rKrC) rzrrrCr9rrr;rN rrvalidate_ok_for_updatevalidate_list_or_nonerrErIr=rMr) rrKrr1r rrCr9rrr;rrzs rZ update_onezAsyncCollection.update_ones@ ""8V4%%f-$$_mD//8 (( +9#+)   & &!   BB B Bc BKtjd|tj|tjd||j |} t |j ||tj|d| |||||| |  d{| jS7w)aM 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 rKrCT) r4rzrrrCr9rrrNrQ) rrKrr1rCr rr9rrrrzs rZ update_manyzAsyncCollection.update_manyKsZ ""8V4%%f-$$_mD//8 (( +9#+)   & &!   rUc(K|jjj|jj|j|j |j |j}|j|j|||d{y7w)azAlias 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. )rrrN) rr get_databaserrxryrzr{drop_collectionr)rrrrdbos rZdropzAsyncCollection.drops@nn##00 NN              !! JJK["   sBB B Bc Ktjd||xs |j}|j} |t | d}t |}|| s t d||d<|F| s|jdkr t dt|tstj|}||d<|j||gd }| tjd | | |d <| | |d <|j|jj|||j | |jj"| d{}t%||S7w) Internal delete helper.rK)r2limitNr5r zPMust be connected to MongoDB 4.4+ to use hint on unacknowledged delete commands.r9)deleter deletesrrr)rrrzrintr*r-rr|r}r r@rr$rrrrr1)rrrBr4rzr r rr9rrrrr delete_docrrs rZ_deletezAsyncCollection._deletesU ""8X6%;);); $11 #ce)n= .y9  ()^__*3 ;'  D$9$9A$=(fdC(%55d;!%Jv !YY7 |T ?  , ,UC 8 GEN  !(GI || NN   '<<>>((+$   &f-  sD+E-D?.Ec  K d  f d } jjjxs jjxr | |t j d{S7w)r^cZ K j| || d{S7w)N) rzr r rr9rrrr)re) rrrrrrBr9rr4r r rrzs rZrez2AsyncCollection._delete_retryable.._delete"sM+# /&    s !+)+rN)rrrr_rrrMapping[str, Any])rrrrzrr=DELETE) rrBr4rzr r rr9rrrres ```````` `` rZ_delete_retryablez!AsyncCollection._delete_retryables 1 9H [_    $^^**;;  0d00 > > Lu9  jj <    sA/B;B<Bc K|j|}t|j|d||||||d{|jS7w)aDelete 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 Frzrr9rrrNrrBrjrrrKrr9rrrrzs rZ delete_onezAsyncCollection.delete_one;sfd//8 ((+#)    & &   3A A A c K|j|}t|j|d||||||d{|jS7w)aDelete 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 TrlNrmrns rZ delete_manyzAsyncCollection.delete_many|sfd//8 ((+#)    & &   rpcK|t|tjsd|i}|j|g|i|}|j d23d{}|cS76yw)azGet 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) Nrro)r|rr findr_)rrKrrcursorrs rZfind_onezAsyncCollection.find_onesg8  j&EV_F63D3F3"LL,  &M ,s*AA AAAAAAc t|g|i|S)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 `_. - :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 `_. )r(rs rZrtzAsyncCollection.findst41$1&11rYcv|jjjr tdt |g|i|S)aQuery 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)rr _encrypterr/r)rs rZfind_raw_batchesz AsyncCollection.find_raw_batchess86 >> + +"#VW W"49$9&99rYc K|j||||j|j||d{}t|dS7w)zInternal count command helper.)ryrxr{rrNr=)rrr{rc)rrrryrrress rZ _count_cmdzAsyncCollection._count_cmdsVMM  +<<**"  3s8} s0AAAc K|j|||dg|j|j||d{}d|vry|dd}|r|dSdS7w)zAInternal helper to run an aggregate that returns a single result.)rrxr{rrNru firstBatchr)rrr{)rrryrrrrbatchs rZ_aggregate_one_resultz%AsyncCollection._aggregate_one_resultsx}}    T<<**%    6 !x . uQx*d*  s2AAAcKdvr td||d< dfd }j|dtjd{S7w)aGet 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/ rz2estimated_document_count does not support sessionsNrcKdji}|jj||||dd{S7w)Ncount)r)rrr})r_serverrryrrrs rZ_cmdz6AsyncCollection.estimated_document_count.._cmdsC $+DJJ"7C JJv $X\]] ]]s9AAAr rrrr`rr_ryOptional[_ServerMode]rrc)r-_retryable_non_cursor_readr=COUNT)rrrrs` ` rZestimated_document_countz(AsyncCollection.estimated_document_counts6  $%YZ Z   'F9  ^1 ^ ^" ^3  ^   ^44T43994UUUUsA AAAcFKd|ig}d|vr"|jd|jdid|vr"|jd|jdi|||d<|jdd d d id ij|id d |vr.t|d tst j |d |d <t|jddj| dfd }j||tjd{S7w)a 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$matchskipz$skipr_z$limitNrz$grouprOz$sum)rr=) aggregaterrur9rcZKj|||d{}|sy|dS7 w)Nrr=)r)rrrryrrrrs rZrz-AsyncCollection.count_documents.._cmd`s@  55osIwF#;  s +) +r) r(rrr|r}r r@r*rrr=r) rrKrrrrrrrs ` @@rZcount_documentszAsyncCollection.count_documentss7|v&' V  OOWfjj&89 : f  OOXvzz'':; <   'F9 1FA;#?@A JJHK V Jvf~s$C+;;F6NKF6N.vzz+t/LM  6 1  " 3   44T7CIINNNNsDD!DD!cK|jj}|j|4d{}|j||j |||d{cdddd{S7@77 #1d{7swYyxYww)z;Non-cursor read helper to handle implicit session creation.N)rrr_retryable_readr)rfuncrrrrs rZrz*AsyncCollection._retryable_non_cursor_reados&&&&w/ b b1//d6O6OPQ6RTUW`aa b b ba b b b bsV,B A/B 'A5A1A5 B )A3*B 1A53B 5B;A> <BB cKtjd||||d<|j||fi|d{S7w)aCreate 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)rr_create_indexes)rrrrrs rZcreate_indexeszAsyncCollection.create_indexes}sIT Y0   'F9 )T))'7EfEEEEs 5><>c Kg|j|tjd{4d{}|jdk\}d fd }|jt |d}|j |d|vr |s td|j||tjt|j||d{dddd{S7777 #1d{7swYSxYww) ayInternal 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. rNr`c3KD]D}t|tst|d|j}j |d|Fyw)Nz4 is not an instance of pymongo.operations.IndexModelr)r|r5r~r#r()indexr#rnamess rZ gen_indexesz4AsyncCollection._create_indexes..gen_indexessY$#E%eZ8'$i'[\ %~~HLL&!12"N#sA A) createIndexesr commitQuorumzRMust be connected to MongoDB 4.4+ to use the commitQuorum option for createIndexes)ryrxrzrrzIterator[Mapping[str, Any]]) rr=CREATE_INDEXESrrr,rr-rr?rr2r) rrrrrsupports_quorumrrrs ` @rZrzAsyncCollection._create_indexess ..w#BTBT.UU  Y]"33q8O #%)II${}:MNC JJv '(< -- . 6 6<"55g>    +  : ;V * +    : sg'C>C C>C"C>BC( C$ C( C>C&C>"C>$C(&C>(C;.C1 /C;6C>cKi}d|vr|jd|d<|||d<t|fi|}|j|g|fi|d{dS7w)afCreates 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`: Used to create an expiring (TTL) collection. MongoDB will automatically delete documents from this collection after 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 `_. .. _wildcard index: https://dochub.mongodb.org/core/index-wildcard/ maxTimeMSNrr)rr5r)rkeysrrr cmd_optionsrs rZrzAsyncCollection.create_indexso\ & '-zz+'>K $  %,K "4*6**d**E7GK{KKQOOKsAAA AcVK|||d<|jdd|i|d{y7w)aDrops 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. Nrr)* _drop_index)rrrrs rZ drop_indexeszAsyncCollection.drop_indexesO s6:   'F9 d>G>v>>>s )')cJK|j|||fi|d{y7w)a.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_namerrrs rZ drop_indexzAsyncCollection.drop_indexp s(^d}gwI&IIIs #!#c 0K|}t|trtj|}t|tst dt ||j|d}|j||||d<|j|tjd{4d{}|j||tjddg|j||d{dddd{y7\7U77 #1d{7swYyxYww)Nz6index_or_name must be an instance of str or list, not ) dropIndexesrrr ns not foundr)ryrrzr)r|r,r _gen_index_namer}r~rrrrr= DROP_INDEXESrr?rr)rrrrrrrrs rZrzAsyncCollection._drop_index s mT *!11-@D$$TUYZ^U_T`ab b"jj48 6  $C N..w#BRBR.SS  W[-- . 6 6"0"!5"55g>       S      slBDC9D%C;&D):D#C=$D( D3C?4D;D=D?DDD DDcBK|j||d{S7w)aGet 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)rrrs rZ list_indexeszAsyncCollection.list_indexes s!6''9999s chKtttttt t fjtj|xr|jxstj}|du dfd }jjj|d4d{}jjj|||tj d{cdddd{S7T77 #1d{7swYyxYww)N)rxryc dK jid}  |d< j||||d{d}t ||j | |j d}|j|d{|S7L#t$r}|jdk7rdgd}Yd}~jd}~wwxYw73w) N) listIndexesrur)rrurr)idr)rexplicit_sessionr)rrr0coder&addressr_maybe_pin_connection) rrrryrruexc cmd_cursorrxcollrrrs rZrz+AsyncCollection._list_indexes.._cmd s #'**;C"!(I 5--c?M[b-cc, !1 * J2248 8 8 #d# 588r> !4  5 9sIB0BBB>B0:B.;B0B B+ B&!B0&B++B0Fr) rrrr`rr_ryr@r,AsyncCommandCursor[MutableMapping[str, Any]])rrrrdrr}rrr?r_txn_read_preferencerrrrr= LIST_INDEXES) rrr read_prefrrrxrrs ` ` @@@rZrzAsyncCollection._list_indexes s. '33&7  N384 5   M>KaKa  b ?!=!=!?ZNDZDZ "$. 1  " )   :   >>>((55guE  ..>>ic.>.>?       sZB;D2DD2;DDD D2DD2DD2D/#D& $D/+D2cK|j||d{}i}|23d{}t|dj|d<t|}|||j d<H7P7E6|Sw)aGet 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. )rrNrr)rr,itemsrr)rrrruinfors rZindex_informationz!AsyncCollection.index_information sD))'7)KK! , ,%e 2 2 45E%LKE&+D6" # L ,6 s0A1A*A1A.A,A.AA1,A..A1c K|diig}ndd|iig}|jttjtt }t |t|||du|dddii}|jjj|j|j|||j tj d{S7w) aReturn 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)rxryrzr{rurrO)rrr retryabler)rrr?rrJr>r"r&rrr get_cursorget_read_preference_performs_writer=LIST_SEARCH_INDEX)rrrrrrrrs rZlist_search_indexesz#AsyncCollection.list_search_indexes6 s0 <$8"#=">H-~>?H  /*22/- !  ,    $D0!L!#45 ^^**:: NN  # #G , ---++ ;    sB:C<C=CcKt|ts tdi|}|j|g||fi|d{dS7w)aCreate 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 NrrX)r|r8_create_search_indexes)rmodelrrrs rZcreate_search_indexz#AsyncCollection.create_search_indexk sJ4%!12$-u-E1d115'7GVvVVXYZZVs5A?AcHK|j|||fi|d{S7w)aCreate 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)rmodelsrrrs rZcreate_search_indexesz%AsyncCollection.create_search_indexes s*,1T00'TVTTTTs " "cK|||d<dfd }|jt|d}|j||j|tj d{4d{}|j ||tjtd{}|dD cgc]} | d c} cdddd{S7c7\7/cc} w7#1d{7swYyxYww) Nrc3tKD].}t|tst|d|j0yw)Nz: is not an instance of pymongo.operations.SearchIndexModel)r|r8r~r#)rrs rZrz;AsyncCollection._create_search_indexes..gen_indexes sE %!%)9:# )#]^nn$  %s58)createSearchIndexesrr)ryrxindexesCreatedrr) rr,rrr=CREATE_SEARCH_INDEXESrr?rr2) rrrrrrrrresprs ` rZrz&AsyncCollection._create_search_indexes s   'F9  %'+iiD`_ 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 FcloseN)rrrr)rrrrr"r&)rrrrrrrs rZrzAsyncCollection.aggregateU sh>>((55gU5K  q(-" !(!4           sV,B A0B (A6A2A6 B *A4+B 2A64B 6B<A? =BB c K|jjjr td|||d<|jjj |d4d{}t t t|jt|tf||dud|d{cdddd{S7T77 #1d{7swYyxYww)abPerform 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 encryptionNrFr)rr) rrryr/rrr)rGrr#r')rrrrrrs rZaggregate_raw_batchesz%AsyncCollection.aggregate_raw_batches s> >> + +"#[\ \   'F9 >>((55gU5K  q#M2%doo4.%,D%8           sZAC B5!C$7B;B7 B;# C/B90C7B;9C;C C C  Cc Kt|tstdt||rd|vr t d|ddk(s|ddk(r t dd|vr|j d s t d |j jd|}|j|d }|j||||d <|j||}|j|tjd {4d {}|j jj|4d {}|j!d||d||j jd {cd d d d {cd d d d {S777]7,77#1d {7swYnxYwd d d d {7y #1d {7swYy xYww)aRename 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 rjrkrrnroz/collection names must not start or end with '.'rlrmz%collection names must not contain '$')renameCollectiontoNrradminT)rzrrr)r|r}r~rr.rrrrrrrr=RENAMErrr) rnew_namerrrrrzrrs rZrenamezAsyncCollection.rename sH(C(GXGWXY Y48+@A A A;# "!4OP P (?8#6#6}#EEF Fnn))*!H:6#'??(C 6  $C N33CA ..w#**.MM  QU~~,,99'B  a!\\"/.2>>00 *      M            sC,G.E?/G7F8G;*F2%F&F2)/F FF  F2(F)F2- G9F :GGF2F F2 G F FF F2 G+F.,G2G8F; 9GGc Kt|tstdt|j|d|d|vr t d||d<t |jdd j|||d<|*t|tstj|}|d< d  fd }j||tj d{S7w) aMGet 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 )distinctrNqueryz can't pass both filter and queryrrr9c nKj||j|ddid{dS7w)NvaluesrO)ryr{rrr)rr{)rrrryrrrs rZrz&AsyncCollection.distinct.._cmdg sRmm$3!%!2!2'#!)1 $  s (535r) rrrr`rr_ryrrr,)r|r}r~rrr-r*rrr r@rr=DISTINCT) rrrKrrr9rrrrs ` @@rZrzAsyncCollection.distinct% s d#s#B49+NO O::c2  & ()KLL$F7O.vzz+t/LM  6  $C N  dC(%55d;CK 1  " 3     $44T7cll4[[[[sC#C/(C-)C/c  Ktjd|t|tst dt |t | jdd j||d | tjd| | d< j| |tj|d d<|tj| d <|td || d <%ttstjj | d  fd } j j"j%j&| |t(j* d{S7w)zInternal findAndModify helper.rKzKreturn_document must be ReturnDocument.BEFORE or ReturnDocument.AFTER, not rN) findAndModifyrnewr projectionfieldsr;r1c zK j}|s tdtd<;|jdkr td|s|jdkr tdd< j |t j ||td{}t||jd S7 w) Nr6r7r8zJMust 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.r9)ryrzrrrrrN) rr-r,rrr?r_FIND_AND_MODIFY_DOC_FIELDSr1r) rrrroutrCrrr9rrzs rZ_find_and_modify_helperzAAsyncCollection._find_and_modify.._find_and_modify_helper s)55L(#,P'+=&9N#((1,,d&$*?*?!*C,s#F   . 6 6+# /7&  C *# .777# # sBB;B9!B;r)rrrr_rrrr)rrr|rrrr*rrrr _fields_list_to_dictr@rLr}rrrrrr=FIND_AND_MODIFY)rrKrr;r1return_documentrCr9rrrr rrrzs` `` @@@rZ_find_and_modifyz AsyncCollection._find_and_modify{ s ""8V4/40]^bcr^s]tu /vzz+t/LM $ VOT ?  & &uc 2CJ 6  !*?? LYCM  (88>CK   Xv ."CM  dC(%55d;33CA  $1 $9H $[_ $  $ $D^^**;;  & & # )) <    sE/E>7E<8E>chKd|d<|||d<|j|||f|||d|d{S7w)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 TremoveNrrr9r)r) rrKrr;r9rrrrs rZfind_one_and_deletez#AsyncCollection.find_one_and_delete s]d x   'F9 *T** J *-D' MS    s )202c Ktj||| d<| | | d<|j|||||f| ||d| d{S7w)a0Finds 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 rNrr)rrLr) rrKrNrr;r1r r9rrrrs rZfind_one_and_replacez$AsyncCollection.find_one_and_replace# syv &&{3&x   'F9 *T**             sAA AA c Ktj|tjd||| d<| | | d<|j||||||f|| | d| d{S7w)aFinds 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 rCrNr)r9rr)rrRrSr) rrKrrr;r1r rCr9rrrrs rZfind_one_and_updatez#AsyncCollection.find_one_and_update sF %%f-$$_mD!x   'F9 *T**              sAA AA )FNNNNN)rAsyncDatabase[_DocumentType]rr}rOptional[bool]rxz(Optional[CodecOptions[_DocumentTypeArg]]ryrrzOptional[WriteConcern]r{Optional[ReadConcern]rrrrrr)rr}rAsyncCollection[_DocumentType])rr})rrrr)rrc)rr)rr)N...) rxrryrrzrr{rrr)...) rxz#bson.CodecOptions[_DocumentTypeArg]ryrrzrr{rrz!AsyncCollection[_DocumentTypeArg])NNNN) rxz-Optional[bson.CodecOptions[_DocumentTypeArg]]ryrrzrr{rrzBAsyncCollection[_DocumentType] | AsyncCollection[_DocumentTypeArg])rrhrrrrK)rrrrrr) NNNNNNNNNNNN)rzOptional[_Pipeline]r Optional[str]rrHr Optional[int]rrrOptional[_CollationIn]rzOptional[Timestamp]rrrrHr Optional[Any]rrrrrz*AsyncCollectionChangeStream[_DocumentType])rrrr}rz$AsyncContextManager[AsyncConnection]) NNTNNNNNFN)rr_rMutableMapping[str, Any]ryrrxzOptional[CodecOptions]rrrz#Optional[Sequence[Union[str, int]]]r{rrzrrrrrrrrrrrh)NF)rr}rr rrrrrrHrrrr)rr rrrr)TNNNN)rz!Sequence[_WriteOp[_DocumentType]]r rr rrrrrrOptional[Mapping]rrAr)rrhr rrzrKr rrrrrrrrr)NNN) r#z%Union[_DocumentType, RawBSONDocument]r rrrrrrrD)TNNN) rz/Iterable[Union[_DocumentType, RawBSONDocument]]r rr rrrrrrrC)FFNNTNNNNNFNNN)$rr_rBrhr##Union[Mapping[str, Any], _Pipeline]r1rr4rrzrr rr rrrrrrC%Optional[Sequence[Mapping[str, Any]]]r9Optional[_IndexKeyHint]rrrrrrHr;rHrrrrH) FFNNTNNNNNNNN)"rBrhr#r"rr}r1rr4rrzrr rr rrrrrrCr#r9r$rrrrHr;rHrrrrH)FNNNNNNN)rKrhrNrhr1rr rrrr9r$rrrrHr;rHrrrrE) FNNNNNNNN)rKrhrr"r1rr rrrrCr#r9r$rrrrHr;rHrrrrE)rKrhrr"r1rrCr#r rrrr9r$rrrrHrrrrE)rrrrrrHrr) NNTNNNFNN)rr_rBrhr4rrzrr rr rrrr9r$rrrrrrHrrrrh)NNTNNNNN)rBrhr4rrzrr rr rrrr9r$rrrrHrrrrh)NNNNN)rKrhrrr9r$rrrrHrrrrB)rKrrrrrrzOptional[_DocumentType])rrrrrzAsyncCursor[_DocumentType])rrrrr"AsyncRawBatchCursor[_DocumentType]) rrrr_ryrrdict[str, Any]rzOptional[Collation]rrc) rr_ryrrr&rrrrrrH)rrrrrrc)NN) rKrhrrrrrrrrc)rzpCallable[[Optional[AsyncClientSession], Server, AsyncConnection, Optional[_ServerMode]], Coroutine[Any, Any, T]]rrrr}rrM) rSequence[IndexModel]rrrrrrr list[str])rr'rrrrrr() rr;rrrrrrrr})rrrrrrrr) rr;rrrrrrrr)rrrrrr)rrrrrr ) rrrrrrrrrz%AsyncCommandCursor[Mapping[str, Any]]) rz*Union[Mapping[str, Any], SearchIndexModel]rrrrrrrr}) rzlist[SearchIndexModel]rrrrrrrr() rr}rrrrrrrr) rr}rrhrrrrrrrr)rzType[_AggregationCommand]rrIrzType[AsyncCommandCursor]rrrrrrHrrrrr!AsyncCommandCursor[_DocumentType]) rrIrrrrHrrrrrr)) rrIrrrrrrrr%) rr}rrrrrrrr )rr}rKrHrrrrr9r$rrrr,)rKrhr1Optional[Union[Mapping[str, Any], Iterable[str]]]r;Optional[_IndexList]r1rr rrCr#r9r$rrrr!rrrr)NNNNNN)rKrhrr*r;r+r9r$rrrrHrrrrrrG)rKrhrNrhrr*r;r+r1rr rr9r$rrrrHrrrrrrG)rKrhrr"rr*r;r+r1rr rrCr#r9r$rrrrHrrrrrrG)PrRrSrTrUrwrrrrrrrpropertyrrrrrr__iter__rnextrrrrrrrapplyrr!r%r.rErIrOrTrWr\rerjrorrrvrtrzr}rrrrrrrrrrrrrrrrrrrrrrrrrrQrVrrrr __classcell__)rs@rZrdrds+ "'BF1504.204~.~~ ~ @ ~ / ~.~,~.~~ ~@ &  L !2  #1403.1   / .  ,  (   2503.1  : / .  ,  +   HL1504.2 + D+ /+ . + , + L + Z4$4/K4 4HD D  ")-'+48+/$(,07;0437!%59/3K%K%K2 K ) K " K*K"5K.K1KK&3K-K 4KZP3P@CP -P2604@D.204,004 %%)88*8/ 8 . 8  8>8,8.8*8.88#8 8@9=#!!*!* ! . ! 6 !! !FO)O.O  O6 [[5904!%!%_*3_*_*%3 _* . _*  _*_* _*_*R"&) ))$ )  ) ' ).)) )\6:04!% > 7> %3> . >  >  > @ [[5904!% HJBHJHJ%3 HJ . HJ  HJ HJHJ^04#)-,0?C(,04 %+/,0!%%^^$^6 ^  ^  ^.^^^'^*^=^&^.^^ )!^"*#^$%^& %'^J04#)-,0?C(,04+/,0!%#1 #1 61  1  1  1 .1 1 1 '1 *1 =1 &1 .1 )1 *!1 "#1 $ %%1 n59,0(,04+/,0!%k !k 'k  k %3 k * k &k .k )k *k k  k b59,0?C(,04+/,0!%v !v 4v  v %3 v * v =v &v .v )v *v v  v x?C59,0(,04+/!%c !c 4c  c = c %3 c *c &c .c )c c  c N15!%8< ) -) ) 6 )  ) `15#,0(,04 %+/!%66$6 6 . 6  66*6&6.66)66 6x15#,0(,04+/!%& #& & . &  &  & *& && .& )& &  & V-1(,04+/!%? !? *? & ? . ? ) ? ?  ? H-1(,04+/!%? !? *? & ? . ? ) ? ?  ? D'+!#!36!BE! !Fz2x:>-/    '  (++/+ + * + . + %+2*V^15!% YO!YO.YO YO  YO YOv b  b . b b  b"15!% -F%-F.-F -F  -F  -F^ [[*+*6R*^a* **^15!% tPtP.tP tP  tP tPp15!%?-?? ?  ?B [[15!% .J$.J..J .J  .J  .J.J` [[15!% $.     <15!%:-:: 6 :>15!%/-// 6 /f15!%(-(( " (X#04!% 3 3 .3  3  3 / 3 p15 [9[.[ [  [ [B15!% U&U.U U  U  U615!% G&G.G G  G  GF15!%  .      L15!% ""&". "  "  " "L15!%,-,, " ,\ [[,0!% 6  /  .    )    +  D15+/!% ^^.^) ^  ^  ^ +^F15!% .... .  . , .` [[15!% ==.= =  = " ==D/304!%(, T\ T\,T\. T\  T\ & T\T\ T\v"& . 5 5?C(,04!%M !M FM # M  M  M =M &M .M M M  M dIM%)(,04+/!%W !W FW # W & W . W )W W W  W zIM%) . 5 5(,04+/!%i !i 'i F i # i  i i &i .i )i i i  i ^IM%) . 5 5?C(,04+/!%S !S 4S F S # S  S S =S &S .S )S S S  S rYrd)xrU __future__rr collectionsrtypingrrrrr r r r r rrrrrrrrrbson.codec_optionsrr bson.objectidr bson.raw_bsonrbson.sonrbson.timestamprpymongorrrr 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/r0pymongo.helpers_sharedr1pymongo.messager2pymongo.operationsr3r4r5r6r7r8r9r:r;r<r=pymongo.read_concernr>pymongo.read_preferencesr?r@pymongo.resultsrArBrCrDrEpymongo.typingsrFrGrHrIpymongo.write_concernrJrKrLrrMr_WriteOprQbsonr[#pymongo.asynchronous.client_sessionr\rr^pymongo.asynchronous.poolr_pymongo.asynchronous.serverr`rarb BaseObjectrdrXrYrZrPs2,"*C")$EE1J9: A:    6@UTWW  CL&l  m }    < <DF;92+0W6 f'')?W6 rY