MongoDB Collection Methods

NameDescription
db.collection.aggregate()Provides access to the aggregation pipeline.
db.collection.bulkWrite()Provides bulk write operation functionality.
db.collection.copyTo()Deprecated. Copies data between collections when run against MongoDB 4.0 or earlier. Unsupported when run against MongoDB 4.2 or later.
db.collection.count()Wraps count to return a count of the number of documents in a collection or a view.
db.collection.countDocuments()Wraps the $group aggregation stage with a $sum expression to return a count of the number of documents in a collection or a view.
db.collection.estimatedDocumentCount()Wraps count to return an approximate count of the documents in a collection or a view.
db.collection.createIndex()Builds an index on a collection.
db.collection.createIndexes()Builds one or more indexes on a collection.
db.collection.dataSize()Returns the size of the collection. Wraps the size field in the output of the collStats.
db.collection.deleteOne()Deletes a single document in a collection.
db.collection.deleteMany()Deletes multiple documents in a collection.
db.collection.distinct()Returns an array of documents that have distinct values for the specified field.
db.collection.drop()Removes the specified collection from the database.
db.collection.dropIndex()Removes a specified index on a collection.
db.collection.dropIndexes()Removes all indexes on a collection.
db.collection.ensureIndex()Deprecated. Use db.collection.createIndex().
db.collection.explain()Returns information on the query execution of various methods.
db.collection.find()Performs a query on a collection or a view and returns a cursor object.
db.collection.findAndModify()Atomically modifies and returns a single document.
db.collection.findOne()Performs a query and returns a single document.
db.collection.findOneAndDelete()Finds a single document and deletes it.
db.collection.findOneAndReplace()Finds a single document and replaces it.
db.collection.findOneAndUpdate()Finds a single document and updates it.
db.collection.getIndexes()Returns an array of documents that describe the existing indexes on a collection.
db.collection.getShardDistribution()For collections in sharded clusters, db.collection.getShardDistribution() reports data of chunk distribution.
db.collection.getShardVersion()Internal diagnostic method for sharded cluster.
db.collection.insert()Creates a new document in a collection.
db.collection.insertOne()Inserts a new document in a collection.
db.collection.insertMany()Inserts several new document in a collection.
db.collection.isCapped()Reports if a collection is a capped collection.
db.collection.latencyStats()Returns latency statistics for a collection.
db.collection.mapReduce()Performs map-reduce style data aggregation.
db.collection.reIndex()Rebuilds all existing indexes on a collection.
db.collection.remove()Deletes documents from a collection.
db.collection.renameCollection()Changes the name of a collection.
db.collection.replaceOne()Replaces a single document in a collection.
db.collection.save()Provides a wrapper around an insert() and update() to insert new documents.
db.collection.stats()Reports on the state of a collection. Provides a wrapper around the collStats.
db.collection.storageSize()Reports the total size used by the collection in bytes. Provides a wrapper around the storageSize field of the collStats output.
db.collection.totalIndexSize()Reports the total size used by the indexes on a collection. Provides a wrapper around the totalIndexSize field of the collStats output.
db.collection.totalSize()Reports the total size of a collection, including the size of all documents and all indexes on a collection.
db.collection.update()Modifies a document in a collection.
db.collection.updateOne()Modifies a single document in a collection.
db.collection.updateMany()Modifies multiple documents in a collection.
db.collection.watch()Establishes a Change Stream on a collection.
db.collection.validate()Performs diagnostic operations on a collection.

参考:
https://docs.mongodb.com/manual/reference/method/js-collection/#collection-methods

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值