The name of this collection此集合的名称
The name of the database this collection belongs to此集合所属的数据库的名称
The namespace of this collection, in the format 此集合的命名空间,格式为${this.dbName}.${this.collectionName}
${this.dbName}.${this.collectionName}
The current readConcern of the collection. 集合的当前readConcern。If not explicitly defined for this collection, will be inherited from the parent DB如果没有为此集合显式定义,将从父数据库继承
The current readPreference of the collection. 集合的当前readPreference
。If not explicitly defined for this collection, will be inherited from the parent DB如果没有为此集合显式定义,将从父数据库继承
The current writeConcern of the collection. 集合的当前writeConcern
。If not explicitly defined for this collection, will be inherited from the parent DB如果没有为此集合显式定义,将从父数据库继承
Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2针对集合执行聚合框架管道,需要MongoDB>=2.2
An array of aggregation pipelines to execute要执行的聚合管道数组
Optional settings for the command命令的可选设置
Perform a bulkWrite operation without a fluent API在没有流畅API的情况下执行bulkWrite操作
Legal operation types are合法操作类型为
insertOne
replaceOne
updateOne
updateMany
deleteOne
deleteMany
Please note that raw operations are no longer accepted as of driver version 4.0.请注意,自驱动程序版本4.0起,不再接受原始操作。
If documents passed in do not contain the _id field, one will be added to each of the documents missing it by the driver, mutating the document. 如果传入的文档不包含_id
字段,则驱动程序将在缺少该字段的每个文档中添加一个字段,从而对文档进行修改。This behavior can be overridden by setting the forceServerObjectId flag.可以通过设置forceServerObjectId
标志来覆盖此行为。
Bulk operations to perform要执行的批量操作
An estimated count of matching documents in the db to a filter.数据库中与筛选器匹配的文档的估计计数。
NOTE: This method has been deprecated, since it does not provide an accurate count of the documents in a collection. 此方法已被弃用,因为它不能提供集合中文档的准确计数。To obtain an accurate count of documents in the collection, use Collection.countDocuments. 要获得集合中文档的准确计数,请使用Collection.countDocuments
。To obtain an estimated count of all documents in the collection, use Collection.estimatedDocumentCount.要获取集合中所有文档的估计计数,请使用Collection.estimatedDocumentCount
。
Gets the number of documents matching the filter. 获取与筛选器匹配的文档数。For a fast count of the total documents in a collection see 有关集合中文档总数的快速计数,请参阅Collection.estimatedDocumentCount
. Collection.estimatedDocumentCount
。Note: When migrating from {@link Collection#count| count} to {@link Collection#countDocuments| countDocuments} the following query operators must be replaced::从Collection.count
迁移到Collection.estimatedDocumentCount
时,必须替换以下查询运算符:
$where |
$expr |
$near |
$geoWithin with $center |
$nearSphere |
$geoWithin with $centerSphere |
Creates an index on the db and collection collection.在数据库和集合集合上创建索引。
The field name or index specification to create an index for要为其创建索引的字段名或索引规范
Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher. 在集合中创建多个索引,仅MongoDB 2.6或更高版本支持此方法。Earlier version of MongoDB will throw a command not supported error.早期版本的MongoDB将抛出一个命令不受支持的错误。
Note: Unlike Collection.createIndex, this function takes in raw index specifications. :与Collection.createIndex
不同,此函数接受原始索引规范。Index specifications are defined here.此处定义了索引规格。
An array of index specifications to be created要创建的索引规范数组
Delete multiple documents from a collection从集合中删除多个文档
The filter used to select the documents to remove用于选择要删除的文档的筛选器
Delete a document from a collection从集合中删除文档
The filter used to select the document to remove用于选择要删除的文档的筛选器
The distinct command returns a list of distinct values for the given key across a collection.distinct命令返回集合中给定键的不同值列表。
Field of the document to find distinct values for要查找不同值的文档字段
Drop the collection from the database, removing it permanently. 从数据库中删除集合,并将其永久删除。New accesses will create a new collection.新访问将创建新集合。
Drops an index from this collection.从此集合中删除索引。
Name of the index to drop.要删除的索引的名称。
Drops all indexes from this collection.删除此集合中的所有索引。
Gets an estimate of the count of documents in a collection using collection metadata. 使用集合元数据获取集合中文档计数的估计值。This will always run a count command on all server versions.这将始终在所有服务器版本上运行count命令。
due to an oversight in versions 5.0.0-5.0.8 of MongoDB, the count command, which estimatedDocumentCount uses in its implementation, was not included in v1 of the Stable API, and so users of the Stable API with estimatedDocumentCount are recommended to upgrade their server version to 5.0.9+ or set apiStrict: false to avoid encountering errors.由于MongoDB 5.0.0-5.0.8版本中的疏忽,estimatedDocumentCount在其实现中使用的count命令未包含在Stable API的v1中,因此建议使用estimatedDocumentCount的Stable API用户将其服务器版本升级到5.0.9+或设置apiStrict:false
以避免遇到错误。
Creates a cursor for a filter that can be used to iterate over results from MongoDB为可用于迭代MongoDB结果的筛选器创建游标
Fetches the first document that matches the filter获取与筛选器匹配的第一个文档
Find a document and delete it in one atomic operation. 在一个原子操作中查找并删除文档。Requires a write lock for the duration of the operation.在操作期间需要写锁。
The filter used to select the document to remove用于选择要删除的文档的筛选器
Find a document and replace it in one atomic operation. 找到一个文档并在一个原子操作中替换它。Requires a write lock for the duration of the operation.在操作期间需要写锁。
The filter used to select the document to replace用于选择要替换的文档的筛选器
The Document that replaces the matching document替换匹配文档的文档
Find a document and update it in one atomic operation. 查找文档并在一个原子操作中更新它。Requires a write lock for the duration of the operation.在操作期间需要写锁。
The filter used to select the document to update用于选择要更新的文档的筛选器
Update operations to be performed on the document要对文档执行的更新操作
Get the db scoped logger获取数据库范围的记录器
Checks if one or more indexes exist on the collection, fails on first non-existing index检查集合上是否存在一个或多个索引,第一个不存在的索引失败
One or more index names to check.要检查的一个或多个索引名称。
Retrieves this collections index info.检索此集合索引信息。
Retrieve all the indexes on the collection.检索集合上的所有索引。
Initiate an In order bulk write operation. 启动有序批量写入操作。Operations will be serially executed in the order they are added, creating a new operation for each switch in types.操作将按添加顺序连续执行,为类型中的每个开关创建一个新操作。
Initiate an Out of order batch write operation. 启动无序批写入操作。All operations will be buffered into insert/update/remove commands executed out of order.所有操作都将缓冲到无序执行的插入/更新/删除命令中。
Inserts a single document or a an array of documents into MongoDB. 将单个文档或文档数组插入MongoDB。If documents passed in do not contain the _id field, one will be added to each of the documents missing it by the driver, mutating the document. 如果传入的文档不包含_id
字段,则驱动程序将在缺少该字段的每个文档中添加一个字段,从而对文档进行修改。This behavior can be overridden by setting the forceServerObjectId flag.可以通过设置forceServerObjectId
标志来覆盖此行为。
The documents to insert要插入的文档
Optional settings for the command命令的可选设置
An optional callback, a Promise will be returned if none is provided一个可选回调,如果没有提供,则返回Promise
Inserts an array of documents into MongoDB. 将文档数组插入MongoDB。If documents passed in do not contain the _id field, one will be added to each of the documents missing it by the driver, mutating the document. 如果传入的文档不包含_id
字段,则驱动程序将在缺少该字段的每个文档中添加一个字段,从而对文档进行修改。This behavior can be overridden by setting the forceServerObjectId flag.可以通过设置forceServerObjectId
标志来覆盖此行为。
The documents to insert要插入的文档
Inserts a single document into MongoDB. 将单个文档插入MongoDB。If documents passed in do not contain the _id field, one will be added to each of the documents missing it by the driver, mutating the document. 如果传入的文档不包含_id
字段,则驱动程序将在缺少该字段的每个文档中添加一个字段,从而对文档进行修改。This behavior can be overridden by setting the forceServerObjectId flag.可以通过设置forceServerObjectId
标志来覆盖此行为。
The document to insert要插入的文档
Returns if the collection is a capped collection如果集合是有上限的集合,则返回
Get the list of all indexes information for the collection.获取集合的所有索引信息的列表。
Optional settings for the command命令的可选设置
Run Map Reduce across a collection. 在集合中运行Map Reduce。Be aware that the inline option for out will return an array of results not a collection.请注意,out的内联选项将返回结果数组,而不是集合。
The mapping function.映射函数。
The reduce function.reduce函数。
Returns the options of the collection.返回集合的选项。
Remove documents.删除文档。
The filter for the remove operation.用于删除操作的筛选器。
Optional settings for the command命令的可选设置
An optional callback, a Promise will be returned if none is provided一个可选回调,如果没有提供,则返回Promise
Rename the collection.重命名集合。
New name of of the collection.集合的新名称。
Replace a document in a collection with another document用另一个文档替换集合中的文档
The filter used to select the document to replace用于选择要替换的文档的筛选器
The Document that replaces the matching document替换匹配文档的文档
Get all the collection statistics.获取所有集合统计信息。
Updates documents.更新文档。
The filter for the update operation.更新操作的筛选器。
The update operations to be applied to the documents要应用于文档的更新操作
Optional settings for the command命令的可选设置
An optional callback, a Promise will be returned if none is provided一个可选回调,如果没有提供,则返回Promise
Update multiple documents in a collection更新集合中的多个文档
The filter used to select the documents to update用于选择要更新的文档的筛选器
The update operations to be applied to the documents要应用于文档的更新操作
Update a single document in a collection更新集合中的单个文档
The filter used to select the document to update用于选择要更新的文档的筛选器
The update operations to be applied to the document要应用于文档的更新操作
Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this collection.创建新的更改流,监视此集合中的新更改(插入、更新、替换、删除和无效)。
Type of the data being detected by the change stream更改流检测到的数据类型
Type of the whole change stream document emitted发出的整个变更流文档的类型
An array of aggregation pipeline stages through which to pass change stream documents. 一组聚合管道阶段,用于传递更改流文档。This allows for filtering (using $match) and manipulating the change stream documents.这允许筛选(使用$match
)和操作变更流文档。
Optional settings for the command命令的可选设置
Generated using TypeDoc
The Collection class is an internal class that embodies a MongoDB collection allowing for insert/find/update/delete and other command operation on that MongoDB collection.Collection
类是一个内部类,它包含一个MongoDB集合,允许对该MongoDB集执行插入/查找/更新/删除和其他命令操作。COLLECTION Cannot directly be instantiatedCOLLECTION无法直接实例化