MongoDB
Collection API Reference
MongoDB collection methods for inserting, querying, updating and aggregating documents.
By EZ4Code Team
Collection
Collection-level operations exposed by the driver and mongo shell.
collection.insertOne(document, options?) -> InsertOneResultInserts a single document into the collection.
Returns: InsertOneResult
collection.find(query, projection?) -> CursorReturns a cursor over documents matching the query, optionally projecting fields.
Returns: Cursor
collection.updateOne(filter, update, options?) -> UpdateResultUpdates the first document matching filter using update operators such as $set.
Returns: UpdateResult
collection.deleteOne(filter, options?) -> DeleteResultDeletes the first document matching the filter.
Returns: DeleteResult
collection.aggregate(pipeline, options?) -> CursorRuns an aggregation pipeline returning a cursor over the resulting documents.
Returns: Cursor
collection.countDocuments(filter, options?) -> numberReturns the number of documents matching the filter.
Returns: number