MongoDB
Add Query
You can add a query step by adding a workflow from the page list.
When you select the MongoDB data source from the workflow step sidebar, the query input window appears.
The method to add a data source is described in the MongoDB data source guide.
Actions
find (Retrieve)
Retrieves documents from a collection.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Filter (filter) | object | Query condition |
Limit (limit) | number | Limit the number of documents to return |
Skip (skip) | number | Skip the number of documents |
Sort (sort) | object | Sort condition |
Query Result
Returns an array of documents retrieved.
[
{ "_id": "507f1f77bcf86cd799439011", "name": "John", "age": 30 },
{ "_id": "507f1f77bcf86cd799439012", "name": "Jane", "age": 25 }
]
insertOne (Insert a single document)
Inserts a single document into a collection.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Document (document) | object | Document data to insert |
Options (options) | object | Insert options |
Query Result
When executing the insertOne action, it returns the ID of the inserted document in the following structure. For more details, please refer to the MongoDB official documentation.
{
"acknowledged": true,
"insertedId": "507f1f77bcf86cd799439011"
}
insertMany (Insert multiple documents)
Inserts multiple documents into a collection at once.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Documents (documents) | array | Documents to insert |
Options (options) | object | Insert options |
Query Result
When executing the insertMany action, it returns the IDs of the inserted documents in the following structure. For more details, please refer to the MongoDB official documentation.
{
"acknowledged": true,
"insertedIds": ["507f1f77bcf86cd799439011", "507f1f77bcf86cd799439012"]
}
replaceOne (Replace a document)
Replaces a single document that matches the filter condition with a new document.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Filter (filter) | object | Filter condition |
Replacement (replacement) | object | New document to replace |
Options (options) | object | Replace options |
Query Result
When executing the replaceOne action, it returns the number of documents replaced in the following structure. For more details, please refer to the MongoDB official documentation.
{
"acknowledged": true,
"matchedCount": 1,
"modifiedCount": 1
}
updateOne (Update a single document)
Updates a single document that matches the filter condition.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Filter (filter) | object | Filter condition |
Update (update) | object | Update content |
Options (options) | object | Update options |
Query Result
When executing the updateOne action, it returns the number of documents modified in the following structure. For more details, please refer to the MongoDB official documentation.
{
"acknowledged": true,
"matchedCount": 1,
"modifiedCount": 1
}
updateMany (Update multiple documents)
Updates all documents that match the filter condition.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Filter (filter) | object | Filter condition |
Updates (updates) | array | Update content |
Options (options) | object | Update options |
Query Result
When executing the updateMany action, it returns the number of documents modified in the following structure. For more details, please refer to the MongoDB official documentation.
{
"acknowledged": true,
"matchedCount": 5,
"modifiedCount": 5
}
deleteOne (Delete a single document)
Deletes a single document that matches the filter condition.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Filter (filter) | object | Delete condition |
Options (options) | object | Delete options |
Query Result
When executing the deleteOne action, it returns the number of documents deleted in the following structure. For more details, please refer to the MongoDB official documentation.
{
"acknowledged": true,
"deletedCount": 1
}
deleteMany (Delete multiple documents)
Deletes all documents that match the filter condition.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Filter (filter) | object | Filter condition |
Options (options) | object | Delete options |
Query Result
When executing the deleteMany action, it returns the number of documents deleted in the following structure. For more details, please refer to the MongoDB official documentation.
{
"acknowledged": true,
"deletedCount": 10
}
distinct (Get unique values)
Retrieves unique values for a specified field.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Field Name (fieldName) | string | Field name to retrieve |
Filter (filter) | object | Filter condition |
Query Result
When executing the distinct action, it returns an array of unique values in the following structure. For more details, please refer to the MongoDB official documentation.
["Seoul", "New York", "London", "Tokyo"]
count (Calculate the number of documents)
Calculates the number of documents that match the filter condition.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Filter (filter) | object | Filter condition |
Options (options) | object | Calculation options |
Query Result
When executing the count action, it returns the number of documents in the following structure. For more details, please refer to the MongoDB official documentation.
{ "n": 42 }
aggregate (Aggregate)
Aggregates data for analysis.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Pipeline (pipeline) | array | Aggregation pipeline |
Query Result
When executing the aggregate action, it returns an array of aggregation results in the following structure. For more details, please refer to the MongoDB official documentation.
[
{
"_id": "Seoul",
"totalPopulation": 9700000,
"avgAge": 35.6
},
{
"_id": "Tokyo",
"totalPopulation": 13960000,
"avgAge": 38.2
}
]
bulkWrite (Bulk Write)
Executes multiple operations at once.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Requests (requests) | object | List of operations to execute |
Query Result
When executing the bulkWrite action, it returns the result of the executed operations in the following structure. For more details, please refer to the MongoDB official documentation.
{
"acknowledged": true,
"insertedCount": 2,
"matchedCount": 3,
"modifiedCount": 3,
"deletedCount": 1,
"upsertedCount": 0
}
runCommand (Run Command)
Executes a database command directly.
Parameters
Name | Type | Description |
---|---|---|
Collection (collection) | string | Collection name |
Command (command) | object | Command to execute |
Query Result
When executing the runCommand action, it returns the result of the executed command in the following structure. For more details, please refer to the MongoDB official documentation.
{
"ok": 1,
"n": 100,
"avgObjSize": 157,
"size": 15700
}