+\hdZddlmZddlmZddlmZmZmZm Z m Z m Z m Z m Z mZmZmZddlmZmZddlmZddlmZddlmZmZdd lmZmZdd lmZm Z dd l!m"Z"m#Z#dd l$m%Z%dd l&m'Z'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2m3Z3m4Z4m5Z5er,ddl6Z6ddlZ6ddl7m8Z8ddl9m:Z:ddl;mZ>ddl?m@Z@ddlAmBZBdZCGddejee3ZEy)zDatabase level operations.) annotations)deepcopy) TYPE_CHECKINGAnyGenericMappingMutableMappingNoReturnOptionalSequenceUnioncastoverload)DEFAULT_CODEC_OPTIONS CodecOptions)DBRef) Timestamp)_csotcommon)_ecoc_coll_name_esc_coll_name) _check_name_CodecDocumentType)CollectionInvalidInvalidOperation)_Op)ReadPreference _ServerMode)_DatabaseAggregationCommand)DatabaseChangeStream Collection) CommandCursor) _CollationIn _DocumentType_DocumentTypeArg _PipelineN) ReadConcern) ClientSession MongoClient) Connection)Server) WriteConcernTc 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)TDatabaseNc 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.mongo_client.MongoClient` 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.database.Database` no longer returns an instance of :class:`~pymongo.collection.Collection` 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/synchronous/database.py z$Database.__init__..sUs||}4UszMongoClient required but given z $externalN)super__init__ codec_optionsread_preference write_concern read_concern pymongo.synchronous.mongo_clientr+ isinstancestr TypeErrortypeany__mro__r3r_name_clientoptionstimeout_timeout) selfclientnamer:r;r<r=r+ __class__s r6r9zDatabase.__init__>sj   1V11  5v55  1V11  /F//   A$$CDJ<PQ Q&+.UV @T@TUU"A$v,BWBWAX YZZ ;    39 .. c|jS)z/The client instance for this :class:`Database`.)rFrJs r6rKzDatabase.clients||rNc|jS)z#The name of this :class:`Database`.)rErPs r6rLz Database.nameszzrN.cyNrJr:r;r<r=s r6 with_optionszDatabase.with_options rNcyrSrTrUs r6rVzDatabase.with_optionsrWrNc t|j|j|xs |j|xs |j|xs |j |xs |j S)aMGet 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:`Collection` is used. :param read_preference: The read preference to use. If ``None`` (the default) the :attr:`read_preference` of this :class:`Collection` 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:`Collection` is used. :param read_concern: An instance of :class:`~pymongo.read_concern.ReadConcern`. If ``None`` (the default) the :attr:`read_concern` of this :class:`Collection` is used. .. versionadded:: 3.8 )r0rFrEr:r;r<r=rUs r6rVzDatabase.with_optionssXJ LL JJ  /T//  3t33  /T//  -D--   rNct|tr4|j|jk(xr|j|j k(St SrS)r?r0rFrKrErLNotImplementedrJothers r6__eq__zDatabase.__eq__s7 eX &<<5<</LDJJ%**4L LrNc||k( SrSrTr\s r6__ne__zDatabase.__ne__s5=  rNcDt|j|jfSrS)hashrFrErPs r6__hash__zDatabase.__hash__sT\\4::.//rNcft|jd|jd|jdS)N(z, ))rBr3rFrErPs r6__repr__zDatabase.__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__zDatabase.__getattr__s^ ??3  :&&''9$AQRVQW,THB8 %%rNct||S)rir!rns r6rmzDatabase.__getitem__s$%%rNc $t||d||||S)a+Get a :class:`~pymongo.collection.Collection` with the given name and options. Useful for creating a :class:`~pymongo.collection.Collection` with different codec options, read preference, and/or write concern from this :class:`Database`. >>> 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:`Database` is used. :param read_preference: The read preference to use. If ``None`` (the default) the :attr:`read_preference` of this :class:`Database` 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:`Database` is used. :param read_concern: An instance of :class:`~pymongo.read_concern.ReadConcern`. If ``None`` (the default) the :attr:`read_concern` of this :class:`Database` is used. Fr!)rJrLr:r;r<r=s r6get_collectionzDatabase.get_collections'X         rNc 8|jd}|r&ttttft |S|j jjr|j jjjr|j jjjj|jd|r`ttttft |j jjj|jd|S|rm|j jjrM||j}|jdr)ttttft |dSy)NencryptedFields.) getrrr@rrrKrGauto_encryption_opts_encrypted_fields_maprL)rJkwargs coll_nameask_dbencrypted_fieldsrGs r6_get_encrypted_fieldszDatabase._get_encrypted_fields2sB"::&78 S)84D+EF F KK   4 4 ##88NN ##88NNRR99+Qyk*S!KK''<<RR99+Qyk2  dkk))>>9o--/G{{,-GCH-x@Q8R/STTrNctd)Nz!'Database' object is not iterable)rArPs r6__next__zDatabase.__next__Ps;<= 4.0. :param session: a :class:`~pymongo.client_session.ClientSession`. :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.change_stream.DatabaseChangeStream` 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_events)r _initialize_cursor)rJpipeline full_document resume_aftermax_await_time_ms batch_size collationstart_at_operation_timesession start_aftercommentfull_document_before_changer change_streams r6watchzDatabase.watch\sJ`-        #    '!5 ((*rNTc |j||d} | rtjd| | |d<|jd} | rtjd| |jj |5} |r3| r | j s%||jd|i| vrtd|zt||d||||} | j|| | cdddS#1swYyxYw)aCreate a new :class:`~pymongo.collection.Collection` 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:`Database` is used. :param read_preference: The read preference to use. If ``None`` (the default) the :attr:`read_preference` of this :class:`Database` is used. :param write_concern: An instance of :class:`~pymongo.write_concern.WriteConcern`. If ``None`` (the default) the :attr:`write_concern` of this :class:`Database` is used. :param read_concern: An instance of :class:`~pymongo.read_concern.ReadConcern`. If ``None`` (the default) the :attr:`read_concern` of this :class:`Database` is used. :param collation: An instance of :class:`~pymongo.collation.Collation`. :param session: a :class:`~pymongo.client_session.ClientSession`. :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 FrtclusteredIndexrL)filterrzcollection %s already existsN) r}rvalidate_is_mappingrvrF _tmp_sessionin_transaction_list_collection_namesrr"_create) rJrLr:r;r<r=r check_existsryr|clustered_indexscolls r6create_collectionzDatabase.create_collectionsz 55fdEJ   & &'8:J K(8F$ % **%56   & &'7 I \\ & &w / 1!"2"2D77~WX7YY'(F(MNND LL #)   s 5ACC"c B|jj|d5}t|t|||dudddii}|jj |j |j |||j tjcdddS#1swYyxYw) an 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:`Database`, 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.database.Database.command` instead. .. note:: The :attr:`~pymongo.database.Database.write_concern` of this collection is automatically applied to this operation. :param pipeline: a list of aggregation pipeline stages :param session: a :class:`~pymongo.client_session.ClientSession`. :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.command_cursor.CommandCursor` 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 aggregatezDatabase.aggregate{s|[[ % %gU % ; q-t#% a'89 C;;..''*!111-- /   s A-BBrFc yrSrT rJconncommandvaluecheckallowable_errorsr;r:r<parse_write_concern_errorrrys r6_commandzDatabase._command rNc yrSrTrs r6rzDatabase._commandrrNc  t|tr||i}|j| |jj | 5} |j |j ||||||| | |j cdddS#1swYyxYw)zInternal command helper.)r<rrrKN)r?r@updaterFrrrE) rJrrrrrr;r:r<rrryrs r6rzDatabase._commands" gs #&Gv \\ & &w / 1<<  +*C||    s /A::Bc yrSrT rJrrrrr;r:rrrys r6rzDatabase.command rNc yrSrTrs r6rzDatabase.commandrrNc f|xst} ||| d<t|tr|} ntt |} |&|xr|j xst j}|jj||| 5\} }|j| |||||| fd|i| cdddS#1swYyxYw)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: >>> db.command("buildinfo") OR >>> db.command({"buildinfo": 1}) For a command where the value matters, like ``{count: collection_name}`` we can do: >>> db.command("count", collection_name) OR >>> db.command({"count": collection_name}) For commands that take additional arguments we can use kwargs. So ``{count: collection_name, query: query}`` becomes: >>> db.command("count", collection_name, query=query) OR >>> 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.client_session.ClientSession`. :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 Database'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_preferencerPRIMARYrF_conn_for_readsr) rJrrrrr;r:rrryopts command_name connections r6rzDatabase.command-sL5 5   'F9  gs #"LW .L  "&I7+G+G+IdnNdNdO \\ ) )/7l ) [ `   4==         s ?B''B0c t|tr|} ntt|} |jj |d5} |xst } |&| xr| jxstj}|jj|| | 5\} }|j| ||dd|| fd| i|} |jd|}| jdrFt|| d| j|| |du| }|j!| |cdddcdddSt#d #1swYnxYw dddy#1swYyxYw) 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.client_session.ClientSession`. :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 Database'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@rrrFrrrrrrrrrrvr#address_maybe_pin_connectionr)rJrrr;r:rrrryr tmp_sessionrrresponser cmd_cursors r6cursor_commandzDatabase.cursor_commandsx gs #"LW .L \\ & &we & <$ P  9$9D&FK$D$D$F#,#++ --o{LY P^(4==# (  **6?*S<<)!. * *; +)0)< '"J44T:%7 P P$ P$ PH++NOO; P P P$ P$ P$ Ps,AD?A6D) D? D))D2 .D??Ec|xr|jxstj} dfd }jj ||||S)z5Same as command but used for retryable read commands.c.j|||S)Nr;r)r)r_serverrr;rrJs r6_cmdz.Database._retryable_read_command.._cmds' == / ! rN) rOptional[ClientSession]rr-rr,r;rreturndict[str, Any])rrrrFr)rJrrrr;rs`` r6_retryable_read_commandz Database._retryable_read_commandss#Ew'C'C'E`.J`J` ,   )   ||++D/7IVVrNc tttttf|j d|}did}|j ||jj|d5}|j||||d}t|||j||d u|jd  } d d d  j|| S#1swYxYw) z Internal listCollections helper.rrr)listCollectionsrFrrrNr)rrr)rr"r r@rrrrrFrrr#rrvr) rJrrr;ryrrrrrs r6_list_collectionszDatabase._list_collections-s ~c3h/ 0     H #$r2 6 \\ & &we & <   dCR] ^F' #!(!4 * J  ((.  s )AC  Cc ||d<|xr|jxstj}||d< dfd }jj |||t j S)Get a cursor over the collections of this database. :param session: a :class:`~pymongo.client_session.ClientSession`. :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.command_cursor.CommandCursor`. .. versionadded:: 3.6 rrc0j||fd|iS)Nr;)r)rrrr;ryrJs r6rz/Database._list_collections_helper.._cmdjs% *4))$cc\bc crNr) rrrr-rr,r;rr'CommandCursor[MutableMapping[str, Any]])rrrrFrrLIST_COLLECTIONS)rJrrrry read_prefrs` ` r6_list_collections_helperz!Database._list_collections_helperJs4  %F8 ?!=!=!?ZNDZDZ   'F9  d, d d d)  d 5  d||++ )W0D0D,  rNc ,|j|||fi|S)r)rrJrrrrys r6list_collectionszDatabase.list_collectionsvs 4-t,,WfgPPPrNc |||d<|d|d<n4tjd|||d<|rt|dk(r d|vrd|d<|jdd|i|Dcgc]}|d c}Scc}w) NrTnameOnlyrrrLrrT)rrlenr)rJrrrryresults r6rzDatabase._list_collection_namess   'F9  >!%F:   & &x 8%F8 c&kQ.6V3C%)z"*G)F)F)aw)aZ`)a %F6N   s A)c ,|j|||fi|S)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.client_session.ClientSession`. :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 )rrs r6list_collection_nameszDatabase.list_collection_namess!@+t**7FGNvNNrNc d|i}|||d<|jj|tj5}|j ||ddg|j |d|cdddS#1swYyxYw)Ndroprrz ns not foundT)rr<rr)rF_conn_for_writesrDROPr_write_concern_for)rJrLrrrrs r6 _drop_helperzDatabase._drop_helpers4.  !(GI  \\ * *7chh * G :=="0"!5"55g>*. !   s (A))A2c|}t|tr |j}t|tst dt ||j d|i|d}|rRtjd||jt|||||jt|||||j|||S)aDrop a collection. :param name_or_collection: the name of a collection to drop or the collection object itself :param session: a :class:`~pymongo.client_session.ClientSession`. :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.database.Database.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 rtTr|rr) r?r"rLr@rArBr}rrrrr)rJname_or_collectionrrr|rLs r6drop_collectionzDatabase.drop_collectionsp" dJ '99D$$QRVW[R\Q]^_ _55  0 1      & &'9;K L   /6QX      0$7RY    w88rNc|}t|tr |j}t|tst dt ||||d}|||d<|||d<|j ||} d} d| vr=| d} | jdd k7s| jd d k7rt|d | d | vrt| d jD]]\} } d| vr>| d} | jdd k7s| jd d k7s8t|d | | jd dr[d} nn| jd dsd} | st|d | | S)aValidate 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: A Collection 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.client_session.ClientSession`. :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/ zAname_or_collection must be an instance of str or Collection, not )validatescandatafullr background)rTr exceptioncorruptz invalid: rawvalidF) r?r"rLr@rArBrfindritemsrv)rJrrrrrrrLrrrinforjress r6validate_collectionzDatabase.validate_collection+sT" dJ '99D$$STXY]T^S_`  XtD  $C N  ! *C c73 v (#Dyy%+tyy/Cr/I'4& 4&(ABB f_ ---/ 3s?x=Dyy-3tyy7Kr7Q/4& 4&0IJJ%0!E GU+E#tfJvj$AB B rNc Dt|tstdt|z|j?|j|j k7r&t d|jd|j d||jjd|jif||d|S)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.client_session.ClientSession`. :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.collection.Collection.find`. .. versionchanged:: 4.1 Added ``comment`` parameter. .. versionchanged:: 3.6 Added ``session`` parameter. zcannot dereference a %sz?trying to dereference a DBRef that points to another database (z not rf_idr) r?rrArBdatabaserE ValueError collectionfind_oneid)rJdbrefrrrys r6 dereferencezDatabase.dereferences>%'5U CD D >> %%..DJJ*F%%*^^$6eDJJ>L /tE$$%.. EHH  '. CI  rN)NNNN)rKMongoClient[_DocumentType]rLr@r:(Optional[CodecOptions[_DocumentTypeArg]]r;Optional[_ServerMode]r<Optional[WriteConcern]r=Optional[ReadConcern]rNone)rr)rr@)N...) r:rr;rr<rr=rrzDatabase[_DocumentType])...) r:z#bson.CodecOptions[_DocumentTypeArg]r;rr<rr=rrzDatabase[_DocumentTypeArg]) r:rr;rr<rr=rrz4Database[_DocumentType] | Database[_DocumentTypeArg])r]rrbool)rint)rLr@rCollection[_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]rrrzOptional[_CollationIn]rzOptional[Timestamp]rrrrr Optional[Any]rrrOptional[bool]rz#DatabaseChangeStream[_DocumentType])NNNNNT)rLr@r:rr;rr<rr=rrrrr!ryrrrrS)rr'rrryrrCommandCursor[_DocumentType])rr,r$Union[str, MutableMapping[str, Any]]rrrrr#Optional[Sequence[Union[str, int]]]r;rr:zCodecOptions[dict[str, Any]]r<rrrrrryrrr)rr,rr#rrrrrr$r;rr: CodecOptions[_CodecDocumentType]r<rrrrrryrrr)rr,rr#rrrrrr$r;rr: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 rrryrrr")rr#rr@rrrr) rr,rrr;rryrrr)NNN) rrrrrr ryrrr) rrrrrr ryrrz list[str])NN)rLr@rrrr rr) r(Union[str, Collection[_DocumentTypeArg]]rrrr r|rrr)FFNNN)rr'rrrrrrrr!rr rr) rrrrrr ryrrzOptional[_DocumentType])+r3 __module__ __qualname__r9propertyrKrLrrVr^r`rcrgrormrrr}__iter__rrrrrapplyrrrrrrrrrrrrrrrrr r __classcell__)rMs@r6r0r0=s CG1504.2K/*K/K/@ K/ / K/ . K/,K/ K/Z#1403.1   / .  ,  !   2503.1  : / .  ,  $   CG1504.2 , ?, /, . , , , > , \ !0J &&CG1504.2 4 4 @4 / 4 . 4 , 4  #4 l'47AE $8H= D )-'+48+/$(,07;+/37!%59/3A%A%A2 A ) A " A*A"5A)A1AA&3A-A -AF [[CG1504.2+/'+YY@Y/ Y . Y , Y)Y%YY #YYxGKM!M,CMVYM %M^ @D'5'='=6K04*/+/  6     >  % 4 . $( )      @D'5'='=:=04*/+/  6     >  % 8 . $( )     (@D'5'='= "04*/+/!!6! !  ! > !%! !.!$(!)!! 3!F@D15"+/!%  5      >  /    )           @D15:=+/!%  5      >  /  8  )            [[@D15W[+/!%~5~~ ~ > ~ / ~U~)~~~ 3~~@ [[15DH+/!%+/dP5dPdP/ dP B dP ) dPdP)dPdP &dPdPT,0 W5WW) W  W0)%    1 >,0.2!% * (* ,*  *  * 1 * \,0.2!% Q(Q,Q Q  Q 1 Q<,0.2!%  ( ,       4,0.2!% O( O, O O  O  OF\`"9KX " [[,0!%8< K9DK9)K9 K9 6 K9  K9K9`+/%)!%RDRR R ) R # RR Rn,0!% ( ( )(  (  ( ! ( rNr0)F__doc__ __future__rcopyrtypingrrrrr r r r r rrbson.codec_optionsrr bson.dbrefrbson.timestamprpymongorrpymongo.commonrrpymongo.database_sharedrrpymongo.errorsrrpymongo.operationsrpymongo.read_preferencesrrpymongo.synchronous.aggregationr!pymongo.synchronous.change_streamr pymongo.synchronous.collectionr""pymongo.synchronous.command_cursorr#pymongo.typingsr$r%r&r'bsonpymongo.read_concernr("pymongo.synchronous.client_sessionr)r>r+pymongo.synchronous.poolr,pymongo.synchronous.serverr-pymongo.write_concernr._IS_SYNC BaseObjectr0rTrNr6rHs!"    C$!:C>"@GB5<TT0@<312 j v  '-"8j rN