+\hkdZddlmZddlmZddlmZmZmZm Z m Z m Z m Z m Z mZmZmZddlmZmZddlmZddlmZddlmZmZdd lmZdd lmZdd lm Z dd l!m"Z"dd l#m$Z$m%Z%ddl&m'Z'm(Z(ddl)m*Z*m+Z+ddl,m-Z-ddl.m/Z/m0Z0ddl1m2Z2m3Z3m4Z4m5Z5er,ddl6Z6ddlZ6ddl7m8Z8ddl9m:Z:ddl;mZ>ddl?m@Z@ddlAmBZBdZCGddejee3ZEy)zDatabase level operations.) annotations)deepcopy) TYPE_CHECKINGAnyGenericMappingMutableMappingNoReturnOptionalSequenceUnioncastoverload)DEFAULT_CODEC_OPTIONS CodecOptions)DBRef) Timestamp)_csotcommon)_DatabaseAggregationCommand)AsyncDatabaseChangeStreamAsyncCollection)AsyncCommandCursor)_ecoc_coll_name_esc_coll_name) _check_name_CodecDocumentType)CollectionInvalidInvalidOperation)_Op)ReadPreference _ServerMode) _CollationIn _DocumentType_DocumentTypeArg _PipelineN)AsyncClientSessionAsyncMongoClient)AsyncConnection)Server) ReadConcern) WriteConcernFc eZdZ d* d+fd Zed,dZed-dZe d. d/dZe d0 d1dZ d* d2dZd3d Z d3d Z d4d Z d-d Z d5d Z d5dZ d* d6dZ d7dZdZd8dZeZd8dZ d9 d:dZej. d; ddZedddej6edddf d?dZedddej6ddddf d@dZdddej6edddf dAdZe dB dCdZe dD dEdZej. dB dFdZej. dG dHdZ d= dId Z dJd!Z! dK dLd"Z" dK dLd#Z# dK dMd$Z$ dK dMd%Z% dN dOd&Z&ej. dK dPd'Z' dQ dRd(Z( dN dSd)Z)xZ*S)T AsyncDatabaseNc t||xs |j|xs |j|xs |j|xs |j ddlm}t|tstdt|t||sFtdt|jDs!tdt|j|dk7r t|||_||_|j$j&|_y)aGet a database by client and name. Raises :class:`TypeError` if `name` is not an instance of :class:`str`. Raises :class:`~pymongo.errors.InvalidName` if `name` is not a valid database name. :param client: A :class:`~pymongo.asynchronous.mongo_client.AsyncMongoClient` instance. :param name: The database name. :param codec_options: An instance of :class:`~bson.codec_options.CodecOptions`. If ``None`` (the default) client.codec_options is used. :param read_preference: The read preference to use. If ``None`` (the default) client.read_preference is used. :param write_concern: An instance of :class:`~pymongo.write_concern.WriteConcern`. If ``None`` (the default) client.write_concern is used. :param read_concern: An instance of :class:`~pymongo.read_concern.ReadConcern`. If ``None`` (the default) client.read_concern is used. .. seealso:: The MongoDB documentation on `databases `_. .. versionchanged:: 4.0 Removed the eval, system_js, error, last_status, previous_error, reset_error_history, authenticate, logout, collection_names, current_op, add_user, remove_user, profiling_level, set_profiling_level, and profiling_info methods. See the :ref:`pymongo4-migration-guide`. .. versionchanged:: 3.2 Added the read_concern option. .. versionchanged:: 3.0 Added the codec_options, read_preference, and write_concern options. :class:`~pymongo.asynchronous.database.AsyncDatabase` no longer returns an instance of :class:`~pymongo.asynchronous.collection.AsyncCollection` for attribute names with leading underscores. You must use dict-style lookups instead:: db['__my_collection__'] Not: db.__my_collection__ rr)z%name must be an instance of str, not c3:K|]}|jdk(yw)r*N)__name__).0clss `/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pymongo/asynchronous/database.py z)AsyncDatabase.__init__..sZcs||'99Zsz$AsyncMongoClient required but given z $externalN)super__init__ codec_optionsread_preference write_concern read_concern!pymongo.asynchronous.mongo_clientr* isinstancestr TypeErrortypeany__mro__r3r_name_clientoptionstimeout_timeout) selfclientnamer:r;r<r=r* __class__s r6r9zAsyncDatabase.__init__>sj   1V11  5v55  1V11  /F//   G$$CDJ<PQ Q&"23ZT&\EYEYZZ"FtF|G\G\F] ^__ ;    8> .. c|jS)z4The client instance for this :class:`AsyncDatabase`.)rFrJs r6rKzAsyncDatabase.clients||rNc|jS)z(The name of this :class:`AsyncDatabase`.)rErPs r6rLzAsyncDatabase.nameszzrN.cyNrJr:r;r<r=s r6 with_optionszAsyncDatabase.with_options rNcyrSrTrUs r6rVzAsyncDatabase.with_optionsrWrNc t|j|j|xs |j|xs |j|xs |j |xs |j S)aaGet a clone of this database changing the specified settings. >>> db1.read_preference Primary() >>> from pymongo.read_preferences import Secondary >>> db2 = db1.with_options(read_preference=Secondary([{'node': 'analytics'}])) >>> db1.read_preference Primary() >>> db2.read_preference Secondary(tag_sets=[{'node': 'analytics'}], max_staleness=-1, hedge=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. .. versionadded:: 3.8 )r0rFrEr:r;r<r=rUs r6rVzAsyncDatabase.with_optionssXJ LL JJ  /T//  3t33  /T//  -D--   rNct|tr4|j|jk(xr|j|j k(St SrS)r?r0rFrKrErLNotImplementedrJothers r6__eq__zAsyncDatabase.__eq__s7 e] +<<5<</LDJJ%**4L LrNc||k( SrSrTr\s r6__ne__zAsyncDatabase.__ne__s5=  rNcDt|j|jfSrS)hashrFrErPs r6__hash__zAsyncDatabase.__hash__sT\\4::.//rNcft|jd|jd|jdS)N(z, ))rBr3rFrErPs r6__repr__zAsyncDatabase.__repr__s/t*%%&a '7r$**qIIrNc |jdr*tt|jd|d|d|d|j |S)Get a collection of this database by name. Raises InvalidName if an invalid collection name is used. :param name: the name of the collection to get _z has no attribute z. To access the z collection, use database[z].) startswithAttributeErrorrBr3 __getitem__rJrLs r6 __getattr__zAsyncDatabase.__getattr__s^ ??3  :&&''9$AQRVQW,THB8 %%rNct||S)rirrns r6rmzAsyncDatabase.__getitem__stT**rNc $t||d||||S)ahGet a :class:`~pymongo.asynchronous.collection.AsyncCollection` with the given name and options. Useful for creating a :class:`~pymongo.asynchronous.collection.AsyncCollection` with different codec options, read preference, and/or write concern from this :class:`AsyncDatabase`. >>> db.read_preference Primary() >>> coll1 = db.test >>> coll1.read_preference Primary() >>> from pymongo import ReadPreference >>> coll2 = db.get_collection( ... 'test', read_preference=ReadPreference.SECONDARY) >>> coll2.read_preference Secondary(tag_sets=None) :param name: The name of the collection - a string. :param codec_options: An instance of :class:`~bson.codec_options.CodecOptions`. If ``None`` (the default) the :attr:`codec_options` of this :class:`AsyncDatabase` is used. :param read_preference: The read preference to use. If ``None`` (the default) the :attr:`read_preference` of this :class:`AsyncDatabase` 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:`AsyncDatabase` is used. :param read_concern: An instance of :class:`~pymongo.read_concern.ReadConcern`. If ``None`` (the default) the :attr:`read_concern` of this :class:`AsyncDatabase` is used. Fr)rJrLr:r;r<r=s r6get_collectionzAsyncDatabase.get_collections'X         rNc TK|jd}|r&ttttft |S|j jjr|j jjjr|j jjjj|jd|r`ttttft |j jjj|jd|S|ru|j jjrU||jd{}|jdr)ttttft |dSy7?w)NencryptedFields.) getrrr@rrrKrGauto_encryption_opts_encrypted_fields_maprL)rJkwargs coll_nameask_dbencrypted_fieldsrGs r6_get_encrypted_fieldsz#AsyncDatabase._get_encrypted_fields2sN"::&78 S)84D+EF F KK   4 4 ##88NN ##88NNRR99+Qyk*S!KK''<<RR99+Qyk2  dkk))>> O3355G{{,-GCH-x@Q8R/STT6sE$F(&F&'AF(ctd)Nz&'AsyncDatabase' object is not iterable)rArPs r6__next__zAsyncDatabase.__next__Ps@AArNcDtt|jd)Nzo objects do not implement truth value testing or bool(). Please compare with None instead: database is not None)NotImplementedErrorrBr3rPs r6__bool__zAsyncDatabase.__bool__Us)!Dz""#$6 6  rNc rKt|||||||||| | | |  } | jd{| S7w)a`Watch changes on this database. Performs an aggregation with an implicit initial ``$changeStream`` stage and returns a :class:`~pymongo.asynchronous.change_stream.AsyncDatabaseChangeStream` cursor which iterates over changes on all collections in this database. Introduced in MongoDB 4.0. .. code-block:: python async with db.watch() as stream: async for change in stream: print(change) The :class:`~pymongo.asynchronous.change_stream.AsyncDatabaseChangeStream` iterable blocks until the next change document is returned or an error is raised. If the :meth:`~pymongo.asynchronous.change_stream.AsyncDatabaseChangeStream.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 db.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`_. :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.AsyncDatabaseChangeStream` 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. .. versionadded:: 3.7 .. seealso:: The MongoDB documentation on `changeStreams `_. .. _change streams specification: https://github.com/mongodb/specifications/blob/master/source/change-streams/change-streams.md )show_expanded_eventsN)r_initialize_cursor)rJpipeline full_document resume_aftermax_await_time_ms batch_size collationstart_at_operation_timesession start_aftercommentfull_document_before_changer change_streams r6watchzAsyncDatabase.watch\sY`2        #    '!5 ..000 1s ,757Tc HK|j||dd{} | rtjd| | |d<|jd} | rtjd| |jj |4d{} |r;| r | j s-||jd|i| d{vrtd|zt||d||||} | j|| d{| cdddd{S777U77 #1d{7swYyxYww)aCreate a new :class:`~pymongo.asynchronous.collection.AsyncCollection` in this database. Normally collection creation is automatic. This method should only be used to specify options on creation. :class:`~pymongo.errors.CollectionInvalid` will be raised if the collection already exists. :param name: the name of the collection to create :param codec_options: An instance of :class:`~bson.codec_options.CodecOptions`. If ``None`` (the default) the :attr:`codec_options` of this :class:`AsyncDatabase` is used. :param read_preference: The read preference to use. If ``None`` (the default) the :attr:`read_preference` of this :class:`AsyncDatabase` is used. :param write_concern: An instance of :class:`~pymongo.write_concern.WriteConcern`. If ``None`` (the default) the :attr:`write_concern` of this :class:`AsyncDatabase` is used. :param read_concern: An instance of :class:`~pymongo.read_concern.ReadConcern`. If ``None`` (the default) the :attr:`read_concern` of this :class:`AsyncDatabase` is used. :param collation: An instance of :class:`~pymongo.collation.Collation`. :param session: a :class:`~pymongo.asynchronous.client_session.AsyncClientSession`. :param check_exists: if True (the default), send a listCollections command to check if the collection already exists before creation. :param kwargs: additional keyword arguments will be passed as options for the `create collection command`_ All optional `create collection command`_ parameters should be passed as keyword arguments to this method. Valid options include, but are not limited to: - ``size`` (int): desired initial size for the collection (in bytes). For capped collections this size is the max size of the collection. - ``capped`` (bool): if True, this is a capped collection - ``max`` (int): maximum number of objects if capped (optional) - ``timeseries`` (dict): a document specifying configuration options for timeseries collections - ``expireAfterSeconds`` (int): the number of seconds after which a document in a timeseries collection expires - ``validator`` (dict): a document specifying validation rules or expressions for the collection - ``validationLevel`` (str): how strictly to apply the validation rules to existing documents during an update. The default level is "strict" - ``validationAction`` (str): whether to "error" on invalid documents (the default) or just "warn" about the violations but allow invalid documents to be inserted - ``indexOptionDefaults`` (dict): a document specifying a default configuration for indexes when creating a collection - ``viewOn`` (str): the name of the source collection or view from which to create the view - ``pipeline`` (list): a list of aggregation pipeline stages - ``comment`` (str): a user-provided comment to attach to this command. This option is only supported on MongoDB >= 4.4. - ``encryptedFields`` (dict): **(BETA)** Document that describes the encrypted fields for Queryable Encryption. For example:: { "escCollection": "enxcol_.encryptedCollection.esc", "ecocCollection": "enxcol_.encryptedCollection.ecoc", "fields": [ { "path": "firstName", "keyId": Binary.from_uuid(UUID('00000000-0000-0000-0000-000000000000')), "bsonType": "string", "queries": {"queryType": "equality"} }, { "path": "ssn", "keyId": Binary.from_uuid(UUID('04104104-1041-0410-4104-104104104104')), "bsonType": "string" } ] } - ``clusteredIndex`` (dict): Document that specifies the clustered index configuration. It must have the following form:: { // key pattern must be {_id: 1} key: , // required unique: , // required, must be `true` name: , // optional, otherwise automatically generated v: , // optional, must be `2` if provided } - ``changeStreamPreAndPostImages`` (dict): a document with a boolean field ``enabled`` for enabling pre- and post-images. .. versionchanged:: 4.2 Added the ``check_exists``, ``clusteredIndex``, and ``encryptedFields`` parameters. .. versionchanged:: 3.11 This method is now supported inside multi-document transactions with MongoDB 4.4+. .. versionchanged:: 3.6 Added ``session`` parameter. .. versionchanged:: 3.4 Added the collation option. .. versionchanged:: 3.0 Added the codec_options, read_preference, and write_concern options. .. _create collection command: https://mongodb.com/docs/manual/reference/command/create FNrtclusteredIndexrL)filterrzcollection %s already exists) r}rvalidate_is_mappingrvrF _tmp_sessionin_transaction_list_collection_namesrr_create) rJrLr:r;r<r=r check_existsryr|clustered_indexscolls r6create_collectionzAsyncDatabase.create_collections9z"&!;!;FD%!PP   & &'8:J K(8F$ % **%56   & &'7 I<<,,W5  !"2"2$"="=fd^]^"="___'(F(MNN"D,,vq) ) ))   Q  ` *%    s|D"DA)D"DD"*D 1D29D +D ,D 1 D"=D >D"D"D  D  D" DD DD"c K|jj|d4d{}t|t|||dudddii}|jj |j |j |||j tjd{cdddd{S777 #1d{7swYyxYww) a Perform a database-level aggregation. See the `aggregation pipeline`_ documentation for a list of stages that are supported. .. code-block:: python # Lists all operations currently running on the server. with client.admin.aggregate([{"$currentOp": {}}]) as cursor: for operation in cursor: print(operation) The :meth:`aggregate` method obeys the :attr:`read_preference` of this :class:`AsyncDatabase`, except when ``$out`` or ``$merge`` are used, in which case :attr:`~pymongo.read_preferences.ReadPreference.PRIMARY` is used. .. note:: This method does not support the 'explain' option. Please use :meth:`~pymongo.asynchronous.database.AsyncDatabase.command` instead. .. note:: The :attr:`~pymongo.asynchronous.database.AsyncDatabase.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 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`. - `let` (dict): 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. :return: A :class:`~pymongo.asynchronous.command_cursor.AsyncCommandCursor` over the result set. .. versionadded:: 3.9 .. _aggregation pipeline: https://mongodb.com/docs/manual/reference/operator/aggregation-pipeline .. _aggregate command: https://mongodb.com/docs/manual/reference/command/aggregate FcloseNcursor firstBatch) user_fields) retryable operation) rKrrr_retryable_read get_cursorget_read_preference_performs_writer! AGGREGATE)rJrrryrcmds r6 aggregatezAsyncDatabase.aggregate{s|;;++G5+A  Q-"t#% a'89 C44''*!111-- 5       sW"C B/C A1B5B1B5 C )B3*C 1B53C 5C;B> <CC rFc  KywrSrT rJconncommandvaluecheckallowable_errorsr;r:r<parse_write_concern_errorrrys r6_commandzAsyncDatabase._command  c  KywrSrTrs r6rzAsyncDatabase._commandrrc bKt|tr||i}|j| |jj | 4d{} |j |j ||||||| | |j d{cdddd{S7L77 #1d{7swYyxYww)zInternal command helper.N)r<rrrK)r?r@updaterFrrrE) rJrrrrrr;r:r<rrryrs r6rzAsyncDatabase._commands" gs #&Gv<<,,W5    +*C||&          sZAB/BB/ 3B>B?B B/BB/BB/B, B# !B,(B/c  KywrSrT rJrrrrr;r:rrrys r6rzAsyncDatabase.command  rc  KywrSrTrs r6rzAsyncDatabase.commandrrc K|xst} ||| d<t|tr|} ntt |} |&|xr|j xst j}|jj||| d{4d{\} }|j| |||||| fd|i| d{cdddd{S7D7=77 #1d{7swYyxYww)aIssue a MongoDB command. Send command `command` to the database and return the response. If `command` is an instance of :class:`str` then the command {`command`: `value`} will be sent. Otherwise, `command` must be an instance of :class:`dict` and will be sent as is. Any additional keyword arguments will be added to the final command document before it is sent. For example, a command like ``{buildinfo: 1}`` can be sent using: >>> await db.command("buildinfo") OR >>> await db.command({"buildinfo": 1}) For a command where the value matters, like ``{count: collection_name}`` we can do: >>> await db.command("count", collection_name) OR >>> await db.command({"count": collection_name}) For commands that take additional arguments we can use kwargs. So ``{count: collection_name, query: query}`` becomes: >>> await db.command("count", collection_name, query=query) OR >>> await db.command({"count": collection_name, "query": query}) :param command: document representing the command to be issued, or the name of the command (for simple commands only). .. note:: the order of keys in the `command` document is significant (the "verb" must come first), so commands which require multiple keys (e.g. `findandmodify`) should be done with this in mind. :param value: value to use for the command verb when `command` is passed as a string :param check: check the response for errors, raising :class:`~pymongo.errors.OperationFailure` if there are any :param allowable_errors: if `check` is ``True``, error messages in this list will be ignored by error-checking :param read_preference: The read preference for this operation. See :mod:`~pymongo.read_preferences` for options. If the provided `session` is in a transaction, defaults to the read preference configured for the transaction. Otherwise, defaults to :attr:`~pymongo.read_preferences.ReadPreference.PRIMARY`. :param codec_options: A :class:`~bson.codec_options.CodecOptions` instance. :param session: A :class:`~pymongo.asynchronous.client_session.AsyncClientSession`. :param comment: A user-provided comment to attach to this command. :param kwargs: additional keyword arguments will be added to the command document before it is sent .. note:: :meth:`command` does **not** obey this AsyncDatabase's :attr:`read_preference` or :attr:`codec_options`. You must use the ``read_preference`` and ``codec_options`` parameters instead. .. note:: :meth:`command` does **not** apply any custom TypeDecoders when decoding the command response. .. note:: If this client has been configured to use MongoDB Stable API (see :ref:`versioned-api-ref`), then :meth:`command` will automatically add API versioning options to the given command. Explicitly adding API versioning options in the command and declaring an API version on the client is not supported. .. versionchanged:: 3.6 Added ``session`` parameter. .. versionchanged:: 3.0 Removed the `as_class`, `fields`, `uuid_subtype`, `tag_sets`, and `secondary_acceptable_latency_ms` option. 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. Added the ``codec_options`` parameter. .. seealso:: The MongoDB documentation on `commands `_. Nrrr) rr?r@nextiter_txn_read_preferencer"PRIMARYrF_conn_for_readsr) rJrrrrr;r:rrryopts command_name connections r6rzAsyncDatabase.command-sL5 5   'F9  gs #"LW .L  "&I7+G+G+IdnNdNdO55 W 6      &                  slBC&C C& C C&"C3C 4C7 C&CC& C& CC&C#C C#C&c `Kt|tr|} ntt|} |jj |d4d{} |xst } |&| xr| jxstj}|jj|| | d{4d{\} }|j| ||dd|| fd| i|d{} |jd|}| jdr^t|| d| j|| |du| }|j!| d{|cdddd{cdddd{St#d 77777<7,7#1d{7swYnxYwdddd{7y#1d{7swYyxYww) a Issue a MongoDB command and parse the response as a cursor. If the response from the server does not include a cursor field, an error will be thrown. Otherwise, behaves identically to issuing a normal MongoDB command. :param command: document representing the command to be issued, or the name of the command (for simple commands only). .. note:: the order of keys in the `command` document is significant (the "verb" must come first), so commands which require multiple keys (e.g. `findandmodify`) should use an instance of :class:`~bson.son.SON` or a string and kwargs instead of a Python `dict`. :param value: value to use for the command verb when `command` is passed as a string :param read_preference: The read preference for this operation. See :mod:`~pymongo.read_preferences` for options. If the provided `session` is in a transaction, defaults to the read preference configured for the transaction. Otherwise, defaults to :attr:`~pymongo.read_preferences.ReadPreference.PRIMARY`. :param codec_options: A :class:`~bson.codec_options.CodecOptions` instance. :param session: A :class:`~pymongo.asynchronous.client_session.AsyncClientSession`. :param comment: A user-provided comment to attach to future getMores for this command. :param max_await_time_ms: The number of ms to wait for more data on future getMores for this command. :param kwargs: additional keyword arguments will be added to the command document before it is sent .. note:: :meth:`command` does **not** obey this AsyncDatabase's :attr:`read_preference` or :attr:`codec_options`. You must use the ``read_preference`` and ``codec_options`` parameters instead. .. note:: :meth:`command` does **not** apply any custom TypeDecoders when decoding the command response. .. note:: If this client has been configured to use MongoDB Stable API (see :ref:`versioned-api-ref`), then :meth:`command` will automatically add API versioning options to the given command. Explicitly adding API versioning options in the command and declaring an API version on the client is not supported. .. seealso:: The MongoDB documentation on `commands `_. FrNTr$cmdr;r)rrexplicit_sessionrz!Command does not return a cursor.)r?r@rrrFrrrr"rrrrrrvraddress_maybe_pin_connectionr )rJrrr;r:rrrryr tmp_sessionrrresponser cmd_cursors r6cursor_commandzAsyncDatabase.cursor_commandsx gs #"LW .L<<,,WE,B& P& Pk 9$9D&FK$D$D$F#,#++ "\\99l P P!.# "( " " **6?*S<<)!3 * *; +)0)< '"J%::4@@@%; P P P& P& P& PL++NOOM& P P ,A9 P& P P P P& P& P& P& P& PsA F. E# F.AF"E&#F+E(,F/"E2E*AE2/E,0E25 FE.F F.E0F. E2#F.&F(F*E2,E2.F0F.2F 8E;9F F F.FF.F+F" F+'F.cK|xr|jxstj} dfd }jj ||||d{S7w)z5Same as command but used for retryable read commands.cJKj|||d{S7w)Nr;r)r)r_serverrr;rrJs r6_cmdz3AsyncDatabase._retryable_read_command.._cmd"s5  / ' s #!#N) rOptional[AsyncClientSession]rr,rr+r;r#returndict[str, Any])rr"rrFr)rJrrrr;rs`` r6_retryable_read_commandz%AsyncDatabase._retryable_read_commands~#Ew'C'C'E`.J`J` 1  " )   \\11$R[\\\\sAA$A"A$c Ktttttf|j d|}did}|j ||jj|d4d{}|j||||d{d }t|||j||du|jd  } dddd{ j|d{| S7{7`7##1d{7swY3xYw7!w) z Internal listCollections helper.rrr)listCollectionsrFrNrrr)rrr)rrr r@rrrrrFrrrrrvr) rJrrr;ryrrrrrs r6_list_collectionszAsyncDatabase._list_collections1s N384 5     H #$r2 6<<,,WE,B  kmmD#XcmddF, #!(!4 * J  ..t444 d     5sfA-D/C+0D3C1 C- 3C1 D C/ D$D%D-C1/D1D7C: 8D?DcK||d<|xr|jxstj}||d< dfd }jj |||t j d{S7w)&Get a cursor over the collections of this database. :param session: a :class:`~pymongo.asynchronous.client_session.AsyncClientSession`. :param filter: A query document to filter the list of collections returned from the listCollections command. :param comment: A user-provided comment to attach to this command. :param kwargs: Optional parameters of the `listCollections command `_ can be passed as keyword arguments to this method. The supported options differ by server version. :return: An instance of :class:`~pymongo.asynchronous.command_cursor.AsyncCommandCursor`. .. versionadded:: 3.6 NrrcLKj||fd|id{S7w)Nr;)r)rrrr;ryrJs r6rz4AsyncDatabase._list_collections_helper.._cmdns= 0//g/>BH s $"$r) rrrr,rr+r;r#r,AsyncCommandCursor[MutableMapping[str, Any]])rr"rrFrr!LIST_COLLECTIONS)rJrrrry read_prefrs` ` r6_list_collections_helperz&AsyncDatabase._list_collections_helperNs4  %F8 ?!=!=!?ZNDZDZ   'F9  1  " )   :  \\11 )W0D0D2    sA6B:A?;BcHK|j|||fi|d{S7w)rN)rrJrrrrys r6list_collectionszAsyncDatabase.list_collections|s*43T227FGVvVVVV " "cK|||d<|d|d<n4tjd|||d<|rt|dk(r d|vrd|d<|jdd|i|d{2cgc3d{}|d77 6c}Scc}ww) NrTnameOnlyrrrLrrT)rrlenr)rJrrrryresults r6rz$AsyncDatabase._list_collection_namess   'F9  >!%F:   & &x 8%F8 c&kQ.6V3C%)z"'Dd&C&C&^G&^W]&^ ^   6N ^    sHABA5B$A=&A9*A7 +A9.A=5B7A99A=:BcHK|j|||fi|d{S7w)aGet a list of all the collection names in this database. For example, to list all non-system collections:: filter = {"name": {"$regex": r"^(?!system\.)"}} db.list_collection_names(filter=filter) :param session: a :class:`~pymongo.asynchronous.client_session.AsyncClientSession`. :param filter: A query document to filter the list of collections returned from the listCollections command. :param comment: A user-provided comment to attach to this command. :param kwargs: Optional parameters of the `listCollections command `_ can be passed as keyword arguments to this method. The supported options differ by server version. .. versionchanged:: 3.8 Added the ``filter`` and ``**kwargs`` parameters. .. versionadded:: 3.6 N)rrs r6list_collection_namesz#AsyncDatabase.list_collection_namess+@1T00&'TVTTTTrc TKd|i}|||d<|jj|tjd{4d{}|j ||ddg|j |d|d{cdddd{S7N7G77 #1d{7swYyxYww)Ndroprrz ns not foundT)rr<rr)rF_conn_for_writesr!DROPr_write_concern_for)rJrLrrrrs r6 _drop_helperzAsyncDatabase._drop_helpers4.  !(GI 66w#((6SS  Wa"0"!5"55g>*. '   S     si:B(B B(B B( ,B5B6B9 B(BB( B(BB(B%B B%!B(cK|}t|tr |j}t|tst dt ||j d|i|dd{}|rbtjd||jt||||d{|jt||||d{|j|||d{S77G7#7 w)aDrop a collection. :param name_or_collection: the name of a collection to drop or the collection object itself :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. For example:: { "escCollection": "enxcol_.encryptedCollection.esc", "ecocCollection": "enxcol_.encryptedCollection.ecoc", "fields": [ { "path": "firstName", "keyId": Binary.from_uuid(UUID('00000000-0000-0000-0000-000000000000')), "bsonType": "string", "queries": {"queryType": "equality"} }, { "path": "ssn", "keyId": Binary.from_uuid(UUID('04104104-1041-0410-4104-104104104104')), "bsonType": "string" } ] } .. note:: The :attr:`~pymongo.asynchronous.database.AsyncDatabase.write_concern` of this database is automatically applied to this operation. .. versionchanged:: 4.2 Added ``encrypted_fields`` parameter. .. versionchanged:: 4.1 Added ``comment`` parameter. .. versionchanged:: 3.6 Added ``session`` parameter. .. versionchanged:: 3.4 Apply this database's write concern automatically to this operation when connected to MongoDB >= 3.4. z3name_or_collection must be an instance of str, not rtTNr|rr) r?rrLr@rArBr}rrrrr)rJname_or_collectionrrr|rLs r6drop_collectionzAsyncDatabase.drop_collectionsp" dO ,99D$$QRVW[R\Q]^_ _!%!;!;  0 1  "     & &'9;K L##/6QX$  ## 0$7RY$  &&tWg>>>   ?sHAC, C$!=C,C&%C,C(C,C* C,&C,(C,*C,cK|}t|tr |j}t|tst dt ||||d}|||d<|||d<|j ||d{} d} d| vr=| d} | jd d k7s| jd d k7rt|d | d | vrt| d jD]]\} } d| vr>| d} | jd d k7s| jd d k7s8t|d | | jddr[d} nn| jddsd} | st|d | | S7w)a Validate a collection. Returns a dict of validation info. Raises CollectionInvalid if validation fails. See also the MongoDB documentation on the `validate command`_. :param name_or_collection: An AsyncCollection object or the name of a collection to validate. :param scandata: Do extra checks beyond checking the overall structure of the collection. :param full: Have the server do a more thorough scan of the collection. Use with `scandata` for a thorough scan of the structure of the collection and the individual documents. :param session: a :class:`~pymongo.asynchronous.client_session.AsyncClientSession`. :param background: A boolean flag that determines whether the command runs in the background. Requires MongoDB 4.4+. :param comment: A user-provided comment to attach to this command. .. versionchanged:: 4.1 Added ``comment`` parameter. .. versionchanged:: 3.11 Added ``background`` parameter. .. versionchanged:: 3.6 Added ``session`` parameter. .. _validate command: https://mongodb.com/docs/manual/reference/command/validate/ zFname_or_collection must be an instance of str or AsyncCollection, not )validatescandatafullNr background)rTr exceptioncorruptz invalid: rawvalidF) r?rrLr@rArBrfindritemsrv)rJrrrrrrrLrrrinforjress r6validate_collectionz!AsyncDatabase.validate_collection2sT" dO ,99D$$XY]^bYcXde  XtD  $C N  ! *C ||C|99 v (#Dyy%+tyy/Cr/I'4& 4&(ABB f_ ---/ 3s?x=Dyy-3tyy7Kr7Q/4& 4&0IJJ%0!E GU+E#tfJvj$AB B 3:sA0E2E3BE "E,/Ec`Kt|tstdt|z|j?|j|j k7r&t d|jd|j d||jjd|jif||d|d{S7w)aDereference a :class:`~bson.dbref.DBRef`, getting the document it points to. Raises :class:`TypeError` if `dbref` is not an instance of :class:`~bson.dbref.DBRef`. Returns a document, or ``None`` if the reference does not point to a valid document. Raises :class:`ValueError` if `dbref` has a database specified that is different from the current database. :param dbref: the reference :param session: a :class:`~pymongo.asynchronous.client_session.AsyncClientSession`. :param comment: A user-provided comment to attach to this command. :param kwargs: any additional keyword arguments are the same as the arguments to :meth:`~pymongo.asynchronous.collection.AsyncCollection.find`. .. versionchanged:: 4.1 Added ``comment`` parameter. .. versionchanged:: 3.6 Added ``session`` parameter. zcannot dereference a %sNz?trying to dereference a DBRef that points to another database (z not rf_idr) r?rrArBdatabaserE ValueError collectionfind_oneid)rJdbrefrrrys r6 dereferencezAsyncDatabase.dereferences>%'5U CD D >> %%..DJJ*F%%*^^$6eDJJ>L 5T%**+44 EHH  '. CI    sB%B.'B,(B.)NNNN)rKAsyncMongoClient[_DocumentType]rLr@r:(Optional[CodecOptions[_DocumentTypeArg]]r;Optional[_ServerMode]r<Optional[WriteConcern]r=Optional[ReadConcern]rNone)rr)rr@)N...) r:rr;rr<rr=rrzAsyncDatabase[_DocumentType])...) r:z#bson.CodecOptions[_DocumentTypeArg]r;rr<rr=rrzAsyncDatabase[_DocumentTypeArg]) r:rr;rr<rr=rrz>AsyncDatabase[_DocumentType] | AsyncDatabase[_DocumentTypeArg])r]rrbool)rint)rLr@rAsyncCollection[_DocumentType]) rLr@r:rr;rr<rr=rrr)ryzMapping[str, Any]rzr@r{rrOptional[Mapping[str, Any]])rr ) NNNNNNNNNNNN)rzOptional[_Pipeline]r Optional[str]rrr Optional[int]rr!rzOptional[_CollationIn]rzOptional[Timestamp]rrrrr Optional[Any]rr rOptional[bool]rz(AsyncDatabaseChangeStream[_DocumentType])NNNNNT)rLr@r:rr;rr<rr=rrrrr#ryrrrrS)rr'rrryrr!AsyncCommandCursor[_DocumentType])rr+r$Union[str, MutableMapping[str, Any]]rrrrr#Optional[Sequence[Union[str, int]]]r;r#r:zCodecOptions[dict[str, Any]]r<rrrrrryrrr)rr+rr%rrrrrr&r;r#r: CodecOptions[_CodecDocumentType]r<rrrrrryrrr)rr+rr%rrrrrr&r;r#r:zEUnion[CodecOptions[dict[str, Any]], CodecOptions[_CodecDocumentType]]r<rrrrrryrr)Union[dict[str, Any], _CodecDocumentType])rTNNNNN)rr%rrrrrr&r;rr:rrrrr"ryrrr)rTNN.NN)rr%rrrrrr&r;rr:r'rrrr"ryrrr)rr%rrrrrr&r;rr:z=Optional[bson.codec_options.CodecOptions[_CodecDocumentType]]rrrr"ryrrr()rNNNNN)rr%rrr;rr:z*Optional[CodecOptions[_CodecDocumentType]]rrrr"rr!ryrrr$)rr%rr@rrrr) rr+rrr;r#ryrrr)NNN) rrrrrr"ryrrr) rrrrrr"ryrrz list[str])NN)rLr@rrrr"rr) r-Union[str, AsyncCollection[_DocumentTypeArg]]rrrr"r|rrr)FFNNN)rr)rrrrrrrr#rr"rr) rrrrrr"ryrrzOptional[_DocumentType])+r3 __module__ __qualname__r9propertyrKrLrrVr^r`rcrgrormrrr}__iter__rrrrrapplyrrr"rrrrrrrrrrrrrr r __classcell__)rMs@r6r0r0=s CG1504.2K//K/K/@ K/ / K/ . K/,K/ K/Z#1403.1   / .  ,  &   2503.1  : / .  ,  )   CG1504.2 , ?, /, . , , , H , \ !0J &+CG1504.2 4 4 @4 / 4 . 4 , 4  (4 l'47AE $8HB D )-'+48+/$(,07;0437!%59/3A%A%A2 A ) A " A*A"5A.A1AA&3A-A 2AF [[CG1504.204'+YY@Y/ Y . Y , Y.Y%YY (YYxLPM!M,HM[^M *M^ @D'5'='=6K04*/04  6     >  % 4 . $( .      @D'5'='=:=04*/04  6     >  % 8 . $( .     (@D'5'='= "04*/04!!6! !  ! > !%! !.!$(!.!! 3!F@D15"04!%  5      >  /    .           @D15:=04!%  5      >  /  8  .            [[@D15W[04!%@5@@ @ > @ / @U@.@@@ 3@@D [[15DH04!%+/fP5fPfP/ fP B fP . fPfP)fPfP +fPfPX15 ]5]]. ]  ]0.%    6 >15.2!% , -, ,,  ,  , 6 , `15.2!% W-W,W W  W 6 W<15.2!%  - ,       615.2!% U- U, U U  U  UFae">P] " [[15!%8< K?IK?.K? K? 6 K?  K?K?`04%)!%RIRR R . R # RR Rn15!% ( ( .(  (  ( ! ( rNr0)F__doc__ __future__rcopyrtypingrrrrr r r r r rrbson.codec_optionsrr bson.dbrefrbson.timestamprpymongorr pymongo.asynchronous.aggregationr"pymongo.asynchronous.change_streamrpymongo.asynchronous.collectionr#pymongo.asynchronous.command_cursorrpymongo.commonrrpymongo.database_sharedrrpymongo.errorsrr pymongo.operationsr!pymongo.read_preferencesr"r#pymongo.typingsr$r%r&r'bson#pymongo.asynchronous.client_sessionr(r>r*pymongo.asynchronous.poolr+pymongo.asynchronous.serverr,pymongo.read_concernr-pymongo.write_concernr._IS_SYNC BaseObjectr0rTrNr6rJs!"    C$!HH;B:C>"@TTFB9202 q F%%w}'=q rN