OptionalallowTreat intermediate (non-self-signed) certificates in the trust CA certificate list as trusted.将信任CA证书列表中的中间(非自签名)证书视为受信任的。
OptionalALPNProtocolsAn array of strings or a Buffer naming possible ALPN protocols. (Protocols should be ordered by their priority.)命名可能的ALPN协议的字符串数组或缓冲区。(协议应按优先级排序。)
OptionalappThe name of the application that created this MongoClient instance. MongoDB 3.4 and newer will print this value in the server log upon establishing each connection. It is also recorded in the slow query log and profile collections创建此MongoClient实例的应用程序的名称。MongoDB 3.4及更高版本将在建立每个连接时在服务器日志中打印此值。它也记录在慢速查询日志和配置文件集合中
OptionalauthThe auth settings for when connection to server.连接到服务器时的身份验证设置。
OptionalauthSpecify the authentication mechanism that MongoDB will use to authenticate the connection.指定MongoDB将用于对连接进行身份验证的身份验证机制。
OptionalauthSpecify properties for the specified authMechanism as a comma-separated list of colon-separated key-value pairs.将指定authMechanism的属性指定为逗号分隔的键值对列表。
OptionalauthSpecify the database name associated with the user’s credentials.指定与用户凭据关联的数据库名称。
OptionalautoOptionally enable in-use auto encryption可选择启用正在使用的自动加密
Automatic encryption is an enterprise only feature that only applies to operations on a collection. Automatic encryption is not supported for operations on a database or view, and operations that are not bypassed will result in error (see libmongocrypt: Auto Encryption Allow-List). 自动加密是一种仅适用于企业的功能,仅适用于对集合的操作。数据库或视图上的操作不支持自动加密,未绕过的操作将导致错误(请参阅libmongocrypt:Auto encryption Allow List)。To bypass automatic encryption for all operations, set bypassAutoEncryption=true in AutoEncryptionOpts.要绕过所有操作的自动加密,请在AutoEncryptionOpts中设置bypassAutoEncryption=true。
Automatic encryption requires the authenticated user to have the listCollections privilege action.自动加密要求经过身份验证的用户具有listCollections权限操作。
If a MongoClient with a limited connection pool size (i.e a non-zero maxPoolSize) is configured with AutoEncryptionOptions, a separate internal MongoClient is created if any of the following are true:如果使用AutoEncryptionOptions配置了具有有限连接池大小(即非零maxPoolSize)的MongoClient,并且满足以下任何条件,则会创建一个单独的内部MongoClient:
false。If an internal MongoClient is created, it is configured with the same options as the parent MongoClient except minPoolSize is set to 0 and AutoEncryptionOptions is omitted.如果创建了一个内部MongoClient,它将配置与父MongoClient相同的选项,除了minPoolSize设置为0并且省略了AutoEncryptionOptions。
OptionalautoOptionalautoOptionalbsonreturn BSON regular expressions as BSONRegExp instances.将BSON正则表达式作为BSONRegExp实例返回。
OptionalcaOptionally override the trusted CA certificates. Default is to trust the well-known CAs curated by Mozilla. Mozilla's CAs are completely replaced when CAs are explicitly specified using this option.可选地覆盖受信任的CA证书。默认情况是信任Mozilla策划的知名CA。当使用此选项明确指定CA时,Mozilla的CA将被完全替换。
OptionalcertCert chains in PEM format. One cert chain should be provided per private key. Each cert chain should consist of the PEM formatted certificate for a provided private key, followed by the PEM formatted intermediate certificates (if any), in order, and not including the root CA (the root CA must be pre-known to the peer, see ca). PEM格式的证书链。每个私钥应提供一个证书链。每个证书链应按顺序由提供的私钥的PEM格式证书组成,然后是PEM格式的中间证书(如果有的话),不包括根CA(根CA必须预先为对等方所知,请参阅CA)。When providing multiple cert chains, they do not have to be in the same order as their private keys in key. If the intermediate certificates are not provided, the peer will not be able to validate the certificate, and the handshake will fail.当提供多个证书链时,它们不必与键中的私钥顺序相同。如果不提供中间证书,对等方将无法验证证书,握手将失败。
Optionalcheckthe serializer will check if keys are valid.串行器将检查键是否有效。
OptionalcheckVerifies the certificate 验证证书cert is issued to hostname.cert是否颁发给hostname。
Returns Error object, populating it with 返回reason, host, and cert on failure. On success, returns undefined.Error对象,在失败时用原因、主机和证书填充它。成功时,返回undefined。
This function is intended to be used in combination with the 此函数旨在与checkServerIdentity option that can be passed to connect and as such operates on a certificate object. For other purposes, consider using x509.checkHost() instead.checkServerIdentity选项结合使用,该选项可以传递以进行连接,因此对证书对象进行操作。出于其他目的,请考虑使用x509.checkHost()。
This function can be overwritten by providing an alternative function as the 通过提供一个替代函数作为传递给options.checkServerIdentity option that is passed to tls.connect(). The overwriting function can call tls.checkServerIdentity() of course, to augment the checks done with additional verification.tls.connect()的options.checkServerIdentity选项,可以覆盖此函数。覆盖函数当然可以调用tls.checkServerIdentity(),通过额外的验证来增强检查。
This function is only called if the certificate passed all other checks, such as being issued by trusted CA (仅当证书通过所有其他检查时,才会调用此函数,例如由受信任的CA(options.ca).options.ca)颁发。
Earlier versions of Node.js incorrectly accepted certificates for a given如果存在匹配的hostname if a matching uniformResourceIdentifier subject alternative name was present (see CVE-2021-44531). uniformResourceIdentifier主题替代名称,则早期版本的Node.js错误地接受了给定主机名的证书(参见CVE-2021-44531)。Applications that wish to accept希望接受uniformResourceIdentifier subject alternative names can use a custom options.checkServerIdentity function that implements the desired behavior.uniformResourceIdentifier主题替代名称的应用程序可以使用自定义options.checkServerIdentity函数来实现所需的行为。
The host name or IP address to verify the certificate against.用于验证证书的主机名或IP地址。
A 表示对等方证书的证书对象。certificate object representing the peer's certificate.
OptionalciphersCipher suite specification, replacing the default. For more information, see modifying the default cipher suite. Permitted ciphers can be obtained via tls.getCiphers(). Cipher names must be uppercased in order for OpenSSL to accept them.密码套件规范,取代默认值。有关更多信息,请参阅修改默认密码套件。允许的密码可以通过tls.getCiphers()获得。密码名称必须大写才能被OpenSSL接受。
OptionalcompressorsAn array or comma-delimited string of compressors to enable network compression for communication between this client and a mongod/mongos instance.一个数组或逗号分隔的压缩器字符串,用于为此客户端和mongod/mongos实例之间的通信启用网络压缩。
OptionalconnectThe time in milliseconds to attempt a connection before timing out.超时前尝试连接的时间(毫秒)。
OptionalcrlPEM formatted CRLs (Certificate Revocation Lists).PEM格式的CRL(证书吊销列表)。
OptionaldirectAllow a driver to force a Single topology type with a connection string containing one host允许驱动程序强制使用包含一个主机的连接字符串的单一拓扑类型
OptionaldriverAllows a wrapping driver to amend the client metadata generated by the driver to include information about the wrapping driver允许包装驱动程序修改驱动程序生成的客户端元数据,以包含有关包装驱动程序的信息 /*
OptionalecdhA string describing a named curve or a colon separated list of curve NIDs or names, for example P-521:P-384:P-256, to use for ECDH key agreement. Set to auto to select the curve automatically. Use crypto.getCurves() to obtain a list of available curve names. 描述命名曲线或冒号分隔的曲线NID或名称列表的字符串,例如P-521:P-384:P-256,用于ECDH键协商。设置为自动以自动选择曲线。使用crypto.getCurves()获取可用曲线名称的列表。On recent releases, openssl ecparam -list_curves will also display the name and description of each available elliptic curve. Default: tls.DEFAULT_ECDH_CURVE.在最近的版本中,openssl ecparam-list_curves还将显示每个可用椭圆曲线的名称和描述。默认值:tls.DEFAULT_ECDH_CURVE。
OptionalenableEnable utf8 validation when deserializing BSON documents. Defaults to true.在反序列化BSON文档时启用utf8验证。默认为true。
OptionalfamilyOptionalfieldsallow to specify if there what fields we wish to return as unserialized raw buffer.允许指定是否有我们希望作为未序列化的原始缓冲区返回的字段。
OptionalforceForce server to assign 强一致性务器分配_id values instead of driver_id值而不是驱动程序
OptionalheartbeatheartbeatFrequencyMS controls when the driver checks the state of the MongoDB deployment. Specify the interval (in milliseconds) between checks, counted from the end of the previous check until the beginning of the next one.hearteatFrequencyMS控制驱动程序何时检查MongoDB部署的状态。指定检查之间的间隔(以毫秒为单位),从上一次检查结束到下一次检查开始计算。
OptionalhintsOptionalignoreserialize will not emit undefined fields note that the driver sets this to serialize不会发出未定义的字段,请注意驱动程序将其设置为falsefalse
OptionaljournalThe journal write concern
OptionalkeepNode.JS socket option to set the time the first keepalive probe is sent on an idle socket. Defaults to 120000msNodeJS套接字选项,用于设置在空闲套接字上发送第一个保活探测的时间。默认值为120000ms
OptionalkeyPrivate keys in PEM format. PEM allows the option of private keys being encrypted. Encrypted keys will be decrypted with options.passphrase. PEM格式的私钥。PEM允许对私钥进行加密。加密键将使用optionspassphrase解密。Multiple keys using different algorithms can be provided either as an array of unencrypted key strings or buffers, or an array of objects in the form 使用不同算法的多个键可以作为未加密键字符串或缓冲区的数组提供,也可以以{pem: <string|buffer>[, passphrase: <string>]}. {pem: <string|buffer>[, passphrase: <string>]}形式的对象数组提供。The object form can only occur in an array. object.passphrase is optional. Encrypted keys will be decrypted with object.passphrase if provided, or options.passphrase if it is not.对象形式只能出现在数组中。objectpassphrase是可选的。加密键将使用object.passphrase(如果提供)解密,如果没有,则使用options.passphrash解密。
OptionalloadInstruct the driver it is connecting to a load balancer fronting a mongos like service指示驱动程序它正在连接到提供类似mongos服务的负载均衡器
OptionallocalOptionallocalOptionallocalThe size (in milliseconds) of the latency window for selecting among multiple suitable MongoDB instances.用于在多个合适的MongoDB实例中进行选择的延迟窗口的大小(以毫秒为单位)。
OptionallookupOptionalmaxThe maximum number of connections that may be in the process of being established concurrently by the connection pool.连接池可以同时建立的最大连接数。
OptionalmaxThe maximum amount of time a connection should remain idle in the connection pool before being marked idle, in milliseconds. If specified, this must be a number greater than or equal to 0, where 0 means there is no limit. Defaults to 0. After this time passes, the idle collection can be automatically cleaned up in the background.连接在标记为空闲之前在连接池中保持空闲的最长时间(毫秒)。如果指定,则必须是大于或等于0的数字,其中0表示没有限制。默认为0。经过这段时间后,可以在后台自动清理空闲的集合。
OptionalmaxThe maximum number of connections in the connection pool.连接池中的最大连接数。
OptionalmaxSpecifies, in seconds, how stale a secondary can be before the client stops using it for read operations.以秒为单位指定在客户端停止将辅助服务器用于读取操作之前,辅助服务器的过时程度。
OptionalminDHSizeOptionalminSets the minimum heartbeat frequency. In the event that the driver has to frequently re-check a server's availability, it will wait at least this long since the previous check to avoid wasted effort.设置最小心跳频率。如果驱动程序必须经常重新检查服务器的可用性,它将在上次检查后至少等待这么长时间,以避免浪费精力。
OptionalminThe minimum number of connections in the connection pool.连接池中的最小连接数。
OptionalmongodbEnable logging level per component or use 为每个组件启用日志记录级别,或使用default to control any unset components.default控制任何未设置的组件。
OptionalmongodbAll BSON documents are stringified to EJSON. This controls the maximum length of those strings. It is defaulted to 1000.所有BSON文档都被字符串化为EJSON。这控制了这些字符串的最大长度。默认值为1000。
OptionalmongodbSpecifies the destination of the driver's logging. The default is stderr.指定驱动程序日志记录的目标。默认值为stderr。
OptionalmonitorEnable command monitoring for this client为此客户端启用命令监视
OptionalnoTCP Connection no delay
OptionalpassphraseShared passphrase used for a single private key and/or a PFX.用于单个私钥和/或PFX的共享密码。
OptionalpfxPFX or PKCS12 encoded private key and certificate chain. pfx is an alternative to providing key and cert individually. PFX is usually encrypted, if it is, passphrase will be used to decrypt it. PFX或PKCS12编码的私钥和证书链。pfx是单独提供键和证书的替代方案。PFX通常是加密的,如果是,将使用密码来解密它。Multiple PFX can be provided either as an array of unencrypted PFX buffers, or an array of objects in the form 多个PFX可以以未加密的PFX缓冲区数组或{buf: <string|buffer>[, passphrase: <string>]}. {buf: <string|buffer>[, passphrase: <string>]}形式的对象数组提供。The object form can only occur in an array. object.passphrase is optional. Encrypted PFX will be decrypted with object.passphrase if provided, or options.passphrase if it is not.对象形式只能出现在数组中。object.passphrase是可选的。加密的PFX将使用object.passphrase(如果提供)解密,如果没有,则使用object.passphrase解密。
OptionalpkA primary key factory function for generation of custom 用于生成自定义_id keys_id键的主键工厂函数
Optionalpromotewhen deserializing a Binary will return it as a node.js Buffer instance.当反序列化Binary时,它将作为nodejs Buffer实例返回。
Optionalpromotewhen deserializing a Long will fit it into a Number if it's smaller than 53 bits.当反序列化一个Long时,如果它小于53位,它将适合一个Number。
Optionalpromotewhen deserializing will promote BSON values to their Node.js closest equivalent types.当反序列化将BSON值提升到其Node.js最接近的等效类型时。
OptionalproxyConfigures a Socks5 proxy host used for creating TCP connections.配置用于创建TCP连接的Socks5代理主机。
OptionalproxyConfigures a Socks5 proxy password when the proxy in proxyHost requires username/password authentication.当proxyHost中的代理需要用户名/密码身份验证时,配置Socks5代理密码。
OptionalproxyConfigures a Socks5 proxy port used for creating TCP connections.配置用于创建TCP连接的Socks5代理端口。
OptionalproxyConfigures a Socks5 proxy username when the proxy in proxyHost requires username/password authentication.当proxyHost中的代理需要用户名/密码身份验证时,配置Socks5代理用户名。
OptionalrawEnabling the raw option will return a Node.js Buffer which is allocated using allocUnsafe API. 启用raw选项将返回使用allocUnsafe API分配的Node.js缓冲区。See this section from the Node.js Docs here for more detail about what "unsafe" refers to in this context. 请参阅Node.js文档中的这一节,以了解在此上下文中“不安全”所指的更多详细信息。If you need to maintain your own editable clone of the bytes returned for an extended life time of the process, it is recommended you allocate your own buffer and clone the contents:如果您需要在进程的延长生命周期内维护返回字节的可编辑克隆,建议您分配自己的缓冲区并克隆内容:
const raw = await collection.findOne({}, { raw: true });
const myBuffer = Buffer.alloc(raw.byteLength);
myBuffer.set(raw, 0);
// Only save and use `myBuffer` beyond this point
Please note there is a known limitation where this option cannot be used at the MongoClient level (see NODE-3946). It does correctly work at 请注意,有一个已知的限制,即此选项不能在MongoClient级别使用(请参阅NODE-3946)。它在Db, Collection, and per operation the same as other BSON options work.Db、Collection和每次操作中都能正常工作,与其他BSON选项的工作方式相同。
OptionalreadSpecify a read concern for the collection (only MongoDB 3.2 or higher supported)指定集合的读取关注(仅支持MongoDB 3.2或更高版本)
OptionalreadThe level of isolation隔离程度
OptionalreadSpecifies the read preferences for this connection指定此连接的读取首选项
OptionalreadSpecifies the tags document as a comma-separated list of colon-separated key-value pairs.将标记文档指定为以逗号分隔的冒号分隔的键值对列表。
OptionalrejectIf true the server will reject any connection which is not authorized with the list of supplied CAs. This option only has an effect if requestCert is true.如果为true,服务器将拒绝任何未使用所提供CA列表授权的连接。此选项仅在requestCert为true时有效。
OptionalreplicaSpecifies the name of the replica set, if the mongod is a member of a replica set.如果mongod是副本集的成员,则指定副本集的名称。
OptionalretryEnables retryable reads.允许可重试的读取。
OptionalretryEnable retryable writes.启用可重试写入。
OptionalsecureAn optional TLS context object from tls.createSecureContext()tls.createSecureContext()中的可选TLS上下文对象
OptionalsecureLegacy mechanism to select the TLS protocol version to use, it does not support independent control of the minimum and maximum version, and does not support limiting the protocol to TLSv1.3. Use minVersion and maxVersion instead. 传统机制用于选择要使用的TLS协议版本,它不支持独立控制最小和最大版本,也不支持将协议限制为TLSv1.3。请改用minVersion和maxVersion。The possible values are listed as SSL_METHODS, use the function names as strings. For example, use 'TLSv1_1_method' to force TLS version 1.1, or 'TLS_method' to allow any TLS protocol version up to TLSv1.3. It is not recommended to use TLS versions less than 1.2, but it may be required for interoperability. Default: none, see minVersion.可能的值列为SSL_METHODS,将函数名用作字符串。例如,使用“TLSv1_1_method”强制TLS版本1.1,或使用“TLS_fethod”允许任何TLS协议版本高达TLSv1.3。不建议使用低于1.2的TLS版本,但可能需要互操作性。默认值:无,请参阅minVersion。
Optionalserializeserialize the javascript functions序列化javascript函数
OptionalserverServer API version服务器API版本
OptionalserverInstructs the driver monitors to use a specific monitoring mode指示驾驶员监视器使用特定的监视模式
OptionalservernameOptionalserverSpecifies how long (in milliseconds) to block for server selection before throwing an exception.指定在抛出异常之前阻止服务器选择的时间(以毫秒为单位)。
OptionalsessionAn optional Buffer instance containing a TLS session.包含TLS会话的可选Buffer实例。
OptionalsocketThe time in milliseconds to attempt a send or receive on a socket before the attempt times out.在尝试超时之前,在套接字上尝试发送或接收的时间(毫秒)。
OptionalsrvThe maximum number of hosts to connect to when using an srv connection string, a setting of 使用srv连接字符串时要连接的最大主机数,设置为0 means unlimited hosts0表示不受限制的主机
OptionalsrvModifies the srv URI to look like:将srv URI修改为如下形式:
_{srvServiceName}._tcp.{hostname}.{domainname}
Querying this DNS URI is expected to respond with SRV records查询此DNS URI预计会返回SRV记录
OptionalsslA boolean to enable or disables TLS/SSL for the connection. (The ssl option is equivalent to the tls option.)一个布尔值,用于启用或禁用连接的TLS/SSL。(ssl选项等效于tls选项。)
Optional ExperimentaltimeoutMSSpecifies the time an operation will run until it throws a timeout error指定操作运行到抛出超时错误的时间
OptionaltlsEnables or disables TLS/SSL for the connection.启用或禁用连接的TLS/SSL。
OptionaltlsBypasses validation of the certificates presented by the mongod/mongos instance绕过mongod/mongos实例提供的证书的验证
OptionaltlsDisables hostname validation of the certificate presented by the mongod/mongos instance.禁用mongod/mongos实例提供的证书的主机名验证。
OptionaltlsCAFileSpecifies the location of a local .pem file that contains the root certificate chain from the Certificate Authority. This file is used to validate the certificate presented by the mongod/mongos instance.指定包含来自证书颁发机构的根证书链的本地pem文件的位置。此文件用于验证mongod/mongos实例提供的证书。
OptionaltlsSpecifies the location of a local .pem file that contains either the client's TLS/SSL certificate and key.指定包含客户端TLS/SSL证书和键的本地pem文件的位置。
OptionaltlsSpecifies the password to de-crypt the tlsCertificateKeyFile.指定对tlsCertificateKeyFile进行解密的密码。
OptionaltlsCRLFileSpecifies the location of a local CRL .pem file that contains the client revokation list.指定包含客户端吊销列表的本地CRL pem文件的位置。
OptionaltlsDisables various certificate validations.禁用各种证书验证。
Optionalusewhen deserializing a Long return as a BigInt.当将Long返回反序列化为BigInt时。
OptionalwThe write concern w value
OptionalwaitThe maximum time in milliseconds that a thread can wait for a connection to become available.线程可以等待连接可用的最长时间(毫秒)。
OptionalwriteA MongoDB WriteConcern, which describes the level of acknowledgement requested from MongoDB for write operations.MongoDB WriteConcern,描述了MongoDB为写操作请求的确认级别。
OptionalwtimeoutMSThe write concern timeout写入关注超时
OptionalzlibAn integer that specifies the compression level if using zlib for network compression.如果使用zlib进行网络压缩,则指定压缩级别的整数。
Describes all possible URI query options for the mongo client
See
/v8.3/reference/connection-string