MongoDB Component
Interact with documents in a MongoDB database
Component key: mongo
Description
MongoDB is a NoSQL database program that uses JSON-like documents with optional schemas. This component allows you to create, read, update, and delete documents inside a MongoDB collection.
Connections
Mongo Connection
Create a new MongoDB connection and enter the connection string for your MongoDB server.
Input | Default | Notes | Example |
---|---|---|---|
Collection string / Required collection | The name of your collection. | customers | |
Cluster Connection String string / Required connectionString | The connection string to use for connecting to a Mongo cluster. From the "Database Deployments" screen, click "Connect" next to a cluster to view the connection string. Refer to https://www.mongodb.com/docs/manual/reference/connection-string/ for details on format and configuration options. | mongodb+srv://<user>:<password>@cluster0.example.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0 | |
Database string / Required database | The name of your database. | admin | |
Use Mongo v4 boolean useV4 | false | Use the older NodeJS v4 driver which is compatible with older MongoDB installations. This component defaults to using the v6 NodeJS driver. |
Actions
Convert Object ID
The Object ID is a unique identifier for a document in a MongoDB collection. This action takes either a string ID or Object ID object, and returns both the ObjectID '_id' and stringified ID versions of the ID which can be used in subsequent actions. | key: convertObjectId
Input | Notes | Example |
---|---|---|
Object ID string / Required objectId | The ID to convert to an Object ID. | 5a9427648b0beebeb69579e7 |
Delete Many
Remove documents from a collection that match a query. | key: deleteMany
Input | Notes |
---|---|
Query Fields string Key Value List document | Filters are used to narrow down the results of a query, or to determine which documents to update or delete. For example, you can search for documents whose key "firstName" is "John". To search by ID, provide a key of "_id". Use the "Comparison Operator" input to specify the type of comparison to perform if needed. |
Connection connection / Required mongoConnection |
Example Payload for Delete Many
{
"data": {
"acknowledged": true,
"deletedCount": 1
}
}
Find All
Retrieve all documents in a collection that match a query. | key: findAll
Input | Default | Notes |
---|---|---|
Comparison Operator string comparisonOperator | The comparison operator to use when filtering documents. Use this field in conjunction with the "Query Fields" input. | |
Convert Values to Numbers boolean convertValuesToNumbers | false | If true, number values detected in the "Query Fields" input will be converted to numeric types. |
Limit string limit | The maximum number of documents to return. | |
Connection connection / Required mongoConnection | ||
Query Fields string Key Value List queryFilter | Filters are used to narrow down the results of a query, or to determine which documents to update or delete. For example, you can search for documents whose key "firstName" is "John". To search by ID, provide a key of "_id". Use the "Comparison Operator" input to specify the type of comparison to perform if needed. | |
Skip string skip | The number of documents to skip when paginating. |
Example Payload for Find All
{
"data": [
{
"_id": "610ae111774d8aaef3b5d2eb",
"id": "610ae111774d8aaef3b5d2eb",
"exampleKey": "exampleValue"
}
]
}
Find One
Retrieve one document in a collection that match a query. If no document is found, an error is thrown. | key: findOne
Input | Default | Notes |
---|---|---|
Comparison Operator string comparisonOperator | The comparison operator to use when filtering documents. Use this field in conjunction with the "Query Fields" input. | |
Convert Values to Numbers boolean convertValuesToNumbers | false | If true, number values detected in the "Query Fields" input will be converted to numeric types. |
Connection connection / Required mongoConnection | ||
Query Fields string Key Value List queryFilter | Filters are used to narrow down the results of a query, or to determine which documents to update or delete. For example, you can search for documents whose key "firstName" is "John". To search by ID, provide a key of "_id". Use the "Comparison Operator" input to specify the type of comparison to perform if needed. |
Example Payload for Find One
{
"data": {
"_id": "610ae111774d8aaef3b5d2eb",
"id": "610ae111774d8aaef3b5d2eb",
"exampleKey": "exampleValue"
}
}
Insert Many
Insert new documents into a collection | key: insertMany
Input | Notes |
---|---|
Documents data / Required Value List documentList | For each item, provide a document ( Javascript Object ) to be inserted into the collection. |
Connection connection / Required mongoConnection |
Example Payload for Insert Many
{
"data": {
"acknowledged": true,
"insertedCount": 3,
"insertedIds": {}
}
}
Insert One
Insert a new document into a collection | key: insertOne
Input | Notes |
---|---|
Document Fields data / Required Key Value List document | Provide key and value pairs that make up the properties of your document. |
Connection connection / Required mongoConnection |
Example Payload for Insert One
{
"data": {
"acknowledged": true,
"insertedId": "610ae111774d8aaef3b5d2eb"
}
}
Raw Request
Execute database commands directly. Does not use collection from connection. | key: rawRequest
Input | Default | Notes | Example |
---|---|---|---|
Execute Command code / Required executeCommand | Provide the command to execute. See https://www.mongodb.com/docs/v6.0/reference/command/ for more information. | ||
Connection connection / Required mongoConnection | |||
Run Admin Command boolean runAdminCommand | false | If true, the command will be executed against the admin database. |
Update Many
Update multiple documents in a collection | key: updateMany
Input | Default | Notes |
---|---|---|
Comparison Operator string comparisonOperator | The comparison operator to use when filtering documents. Use this field in conjunction with the "Query Fields" input. | |
Convert Values to Numbers boolean convertValuesToNumbers | false | If true, number values detected in the "Query Fields" input will be converted to numeric types. |
Update Fields data Key Value List documentUpdate | Provide key and value pairs to be inserted/updated in your document. | |
Connection connection / Required mongoConnection | ||
Query Fields string Key Value List queryFilter | Filters are used to narrow down the results of a query, or to determine which documents to update or delete. For example, you can search for documents whose key "firstName" is "John". To search by ID, provide a key of "_id". Use the "Comparison Operator" input to specify the type of comparison to perform if needed. | |
Upsert boolean upsert | false | If true, creates a new document when no document matches the query criteria. |
Update One
Update a single document in a collection | key: updateOne
Input | Default | Notes |
---|---|---|
Query Fields string Key Value List document | Filters are used to narrow down the results of a query, or to determine which documents to update or delete. For example, you can search for documents whose key "firstName" is "John". To search by ID, provide a key of "_id". Use the "Comparison Operator" input to specify the type of comparison to perform if needed. | |
Update Fields data Key Value List documentUpdate | Provide key and value pairs to be inserted/updated in your document. | |
Connection connection / Required mongoConnection | ||
Upsert boolean upsert | false | If true, creates a new document when no document matches the query criteria. |
Example Payload for Update One
{
"data": {
"acknowledged": true,
"modifiedCount": 1,
"upsertedId": null,
"upsertedCount": 0,
"matchedCount": 1
}
}