Mongo DB makes operations in a Mongo database connection, returning only one JSON object.
Important: mind the memory consumption for big datasets.
Parameters
Take a look at the configuration parameters of the component. Parameters supported by Double Braces expressions are marked with (DB)
.
Currently, the component only supports Basic and Certificate Chain accounts, and it must be informed through the Account field, not directly in the connection string.
You can:
document = "{\"data\": [{\"object\": 1}, {\"object\": 2}]}"
get some JSON of the message, that will search the 'data' object of the message:
document = "{{ message.$.data }}
document = "{\"data\": [{\"object\": {{ message.$.id1 }}}, {\"object\": {{ message.$.id2 }}}]}"]
If MongoDB needs some authentication, you must create an account (BASIC type) and use it in the component.
To convert Double Braces, we use JSON Path specifications. Read the documentation about JSON Path on GitHub.
Mongo DB in Action
Operation Find
Config
Copy {
"operation": "FIND",
"databaseName": "test",
"collectionName": "model",
"url": "mongodb://localhost:27017",
"query": "{_id: ObjectId({{ message.$.parameters.id }})}",
"failOnError": false
}
Input
Copy {
"parameters": {
"id": "5c87c7af06c3af7dbedc7bb3"
}
}
Output
Copy {
"data": [...some data...],
"rowCount": 10,
"updateCount": 0
}
Operation Replace One
Config
Copy {
"operation": "REPLACE_ONE",
"databaseName": "test",
"collectionName": "model",
"document": "{\"data\": [{\"object\": 1}, {\"object\": 2}]}",
"url": "mongodb://localhost:27017",
"query": "{_id: ObjectId({{ message.$.parameters.id }})}",
"failOnError": false
}
Input
Copy {
"parameters": {
"id": "5c87c7af06c3af7dbedc7bb3"
}
}
Output
Copy {
"data": {},
"rowCount": 0,
"updateCount": 1
}
Operation Update
Config
Copy {
"operation": "UPDATE",
"databaseName": "test",
"collectionName": "model",
"document": "{\"$set\": {\"data\": [{\"object\": 1}, {\"object\": 2}]}}",
"url": "mongodb://localhost:27017",
"query": "{_id: ObjectId({{ message.$.parameters.id }})}",
"failOnError": false
}
Input
Copy {
"parameters": {
"id": "5c87c7af06c3af7dbedc7bb3"
}
}
Output
Copy {
"data": {},
"rowCount": 0,
"updateCount": 1
}
Operation Update Many
Config
Copy {
"operation": "UPDATE_MANY",
"databaseName": "test",
"collectionName": "model",
"document": "{\"$set\": {\"data\": [{\"object\": 1}, {\"object\": 2}]}}",
"url": "mongodb://localhost:27017",
"query": "{name: ObjectId({{ message.$.parameters.name }})}",
"failOnError": false
}
Input
Copy {
"parameters": {
"name": "NAME"
}
}
Output
Copy {{
"data": {},
"rowCount": 0,
"updateCount": 1
}
Operation Delete
Config
Copy {
"operation": "DELETE",
"databaseName": "test",
"collectionName": "model",
"url": "mongodb://localhost:27017",
"query": "{_id: ObjectId({{ message.$.parameters.id }})}",
"failOnError": false
}
Input
Copy {
"parameters": {
"id": "5c87c7af06c3af7dbedc7bb3"
}
}
Output
Copy {
"data": {},
"rowCount": 10,
"updateCount": 0
}
Operation Delete Many
Config
Copy {
"operation": "DELETE_MANY",
"databaseName": "test",
"collectionName": "model",
"url": "mongodb://localhost:27017",
"query": "{name: {{ message.$.data.name }}}",
"failOnError": false
}
Input
Copy {
"data": {
"name": "NAME"
}
}
Output
Copy {
"data": {},
"rowCount": 10,
"updateCount": 0
}
Operation Insert
Config
Copy {
"operation": "INSERT",
"databaseName": "test",
"collectionName": "model",
"document": "{\"data\": {{ message.$.body }}}",
"url": "mongodb://localhost:27017",
"failOnError": false
}
Input
Copy {
"parameters": {
"id": "5c87c7af06c3af7dbedc7bb3"
},
"body": [
{"a": 1},
{"a": 2}
]
}
Output
Copy {
"data": {},
"rowCount": 0,
"updateCount": 1
}
Operation Insert Many
Config
Copy {
"operation": "INSERT_MANY",
"databaseName": "test",
"collectionName": "model",
"document": "{{ message.$.body }}",
"url": "mongodb://localhost:27017",
"failOnError": false
}
Input
Copy {
"parameters": {
"id": "5c87c7af06c3af7dbedc7bb3"
},
"body": [
{"a": 1},
{"a": 2}
]
}
Output
Copy {
"data": {},
"rowCount": 0,
"updateCount": 1
}
Operation Aggregate
Config
Copy {
"operation": "AGGREGATE",
"databaseName": "test",
"collectionName": "model",
"url": "mongodb://localhost:27017",
"query": "[{\"$match\":{\"zip\":\"90210\"}},{\"$group\":{\"_id\":null,\"count\":{\"$sum\":1}}}]",
"failOnError": false
}
Input
Copy {
"parameters": {
"id": "5c87c7af06c3af7dbedc7bb3"
}
}
Output
Copy {
"data": [...some data...],
"rowCount": 10,
"updateCount": 0
}
Operation List Indexes
Config
Copy {
"operation": "LIST_INDEXES",
"databaseName": "test",
"collectionName": "model",
"url": "mongodb://localhost:27017",
"failOnError": false
}
Input
Output
Copy {
"data": [...some data...],
"rowCount": 10
}
Operation Create Index
Config
Copy {
"operation": "CREATE_INDEX",
"databaseName": "test",
"collectionName": "model",
"url": "mongodb://localhost:27017",
"expireAfterSeconds": "3600",
"query": "{ \"createdAt\": 1 }",
"failOnError": false
}
Input
Output
Copy {
"data": "createdAt_1",
"updateCount": 1
}
Operation Drop Index
Config
Copy {
"operation": "DROP_INDEX",
"databaseName": "test",
"collectionName": "model",
"url": "mongodb://localhost:27017",
"query": "{ \"createdAt\": 1 }",
"failOnError": false
}
Input
Output
Copy {
"data": { },
"updateCount": 1
}
Mongo DB supports static Double Braces in the following parameters that were previously specified:
Last updated 11 months ago