Navigation

MongoDB Actions

The following actions are available for MongoDB in functions and in the client SDKs.

Important

In order to use MongoDB actions, you must have rules set up for each namespace included in the operation.

Action Description
mongodb.db() Return a database handle object that represents a database in a linked MongoDB Cluster. Call database.collection() on the database handle to retrieve a collection handle.
database.collection() Return a collection handle object that represents a collection in a database.
collection.find() Find all documents in a collection or view that match the provided query predicates and return a cursor that points to them.
collection.findOne() Return a single document from a collection or view. If multiple documents satisfy the query, this method returns the first document according to the query’s sort order or natural order.
collection.findOneAndUpdate() Update a single document in a collection or view based on a query filter and return the document in either its pre-update or post-update form. Unlike collection.updateOne(), this action allows you to atomically find, update, and return a document with the same command.
collection.findOneAndReplace() Overwrite a single document in a collection or view based on a query filter and return the document in either its pre-replacement or post-replacement form. Unlike collection.updateOne(), this action allows you to atomically find, replace, and return a document with the same command.
collection.findOneAndDelete() Remove a single document from a collection based on a query filter and return a document with the same form as the document immediately before it was deleted. Unlike collection.deleteOne(), this action allows you to atomically find and delete a document with the same command.
collection.count() Return the number of documents in a collection or view that match the specified query filter.
collection.insertOne() Insert a single document into a collection and return the _id of the inserted document.
collection.insertMany() Insert one or more documents into a collection and return a list of the _id values for each inserted document.
collection.updateOne() Update a single document in a collection based on a query filter.
collection.updateMany() Update one or more documents in a collection based on a query filter.
collection.deleteOne() Remove a single document from the collection based on a query filter.
collection.deleteMany() Remove one or more documents from the collection based on a query filter.
collection.aggregate() Execute an aggregation pipeline and return a cursor that points to the result.