MongoDB Collection Methods
MongoDB provides a set of methods for managing collections, allowing you to perform operations such as creating, deleting, renaming, and listing collections. This page summarizes the collection methods available in MongoDB.
-
aggregate
The MongoDBaggregate()method can be used to perform aggregation operations on a MongoDB collection and supports SQL-like aggregation operations such asgroup,sort,project, etc. -
bulkWrite
ThebulkWrite()method in MongoDB is an API for performing batch operations that support multiple types of operations such as inserts, updates, and deletes in a single request. -
count
Thecount()method is an aggregation function in MongoDB used to count the number of documents that meet specified conditions. -
countDocuments
The MongoDBcountDocuments()method is a commonly used query method that can be used to count the number of documents that meet certain criteria. -
createIndex
The MongoDBcreateIndex()method is used to create an index. -
createIndexes
ThecreateIndexes()method in MongoDB is used to create one or more indexes in a collection. -
dataSize
dataSize()is a method in MongoDB used to return the size of all documents in a collection or index in bytes. -
deleteMany
ThedeleteMany()method is a method for deleting multiple documents in MongoDB. -
deleteOne
The MongoDBdeleteOne()method is mainly used to delete a single document in a collection -
distinct
Thedistinct()method is a method in MongoDB used to obtain the unique values of a specified field in a collection. -
drop
In MongoDB, thedrop()method is used to delete a specified collection. -
dropIndex
The MongoDBdropIndex()method is used to remove an index. -
dropIndexes
ThedropIndexes()method is a MongoDB method used to delete one or more indexes in a collection. -
ensureIndex
TheensureIndex()method is a method in MongoDB used to create indexes. -
estimatedDocumentCount
In MongoDB, theestimatedDocumentCount()method is used to estimate the number of documents in a collection, which can improve query performance when dealing with large datasets. -
explain
The MongoDBexplain()method analyzes detailed information about query execution, including the indexes used, the number of documents scanned, and more. -
find
find()is one of the most commonly used methods in MongoDB for retrieving documents from a collection. -
findAndModify
findAndModify()is a collection operation method in MongoDB that allows users to return the document before the update when performing an update operation. -
findOne
ThefindOne()method is a query method in MongoDB database used to query a single document in a collection that matches the specified criteria and return that document. -
findOneAndDelete
In MongoDB,findOneAndDelete()is a method used to find and delete a single document. -
findOneAndReplace
ThefindOneAndReplace()method in MongoDB is used to find the first document in a collection that matches a given condition and replaces it with a new document. -
findOneAndUpdate
The MongoDBfindOneAndUpdate()method can find and modify or update a document based on the query condition. -
getIndexes
ThegetIndexes()method is a built-in method of MongoDB that can return all index information in a collection. -
getShardDistribution
getShardDistribution()is a method in MongoDB used to query the distribution of a sharded collection. -
getShardVersion
ThegetShardVersion()method is a method in MongoDB used to retrieve shard version information. -
hideIndex
The MongoDBhideIndex()method is used to hide a specific index in a specified collection. -
insertMany
TheinsertMany()method in MongoDB is used to insert multiple new documents into a MongoDB database. -
insertOne
TheinsertOne()method in MongoDB is used to insert a single new document into a database. -
Introduction to MongoDB collection.insert() Method
Theinsert()method in MongoDB is used to insert a new document into a MongoDB database. -
Introduction to MongoDB collection.update() Method
In MongoDB, theupdate()method is used to modify data in one or more documents. -
isCapped
TheisCapped()method is a built-in method in MongoDB used to check if a collection is a capped collection. -
latencyStats
latencyStats()is a method in MongoDB that returns latency statistics for operations during a specified time period. -
mapReduce
ThemapReduce()method in MongoDB is a powerful data processing tool that can perform custom aggregation and processing on data in a collection. -
reIndex
ThereIndex()method is a method in MongoDB used to rebuild indexes. -
remove
The MongoDBremove()method is used to remove documents from a MongoDB database. -
renameCollection
renameCollection()is a collection management method in MongoDB that can be used to rename a collection. -
replaceOne
replaceOne()is an update operation in MongoDB that replaces a document that matches a specified filter. -
stats
stats()is a method in MongoDB that can be used to retrieve statistics information about a collection. -
storageSize
storageSize()is a method in MongoDB that can be used to retrieve the storage size of a collection. -
totalIndexSize
totalIndexSize()is a method in MongoDB that can be used to get the total size of all indexes in a collection. -
totalSize
totalSize()is a method in MongoDB that can be used to get the total size of a collection. -
unhideIndex
unhideIndex()is a method in MongoDB used to hide specified indexes in the database. -
updateMany
TheupdateMany()method method can be used to update data in multiple documents at the same time. -
updateOne
TheupdateOne()method is one of the methods in MongoDB used to update a single document. -
validate
Thevalidate()method is used in MongoDB to check if a collection is valid. -
watch
Thewatch()method in MongoDB can monitor data changes in a collection and return corresponding change streams.