MongoDB QL
Description
The MongoDB QL action executes one or more JSON instructions from this action’s configuration or from a file.
This action can be used to execute administrative instructions on a Mongo Database.
You can execute more than one JSON instruction.
Any JSON Instruction that can be used inside MongoDB’s runCommand(), can be executed by this action.
MongoDB documentation : https://www.mongodb.com/docs/manual/reference/command/
Options
| Option | Description |
|---|---|
Action name |
The name of the workflow action. |
MongoDB Connection |
The MongoDB connection to use. |
Use external file |
Enable this option to load the JSON instructions from a file. |
Filename |
The filename for the file with JSON instructions. |
Use variable substitution |
Enables variables to be used in the Script. |
Fail on write errors |
Make the action false when MongoDB reports write errors in its answer ( |
JSON |
The JSON instructions to execute: one JSON document, or several in a JSON array ( |
Examples
Single instruction
{"create":"hop_collection"}
Multiple instructions
[
{"create":"hop_collection"},
{"drop": "hop_collection" }
]
Result
What this action passes on to the next action. See Action results for how results travel through a workflow.
| Result | Value |
|---|---|
True |
Every instruction ran, with 0 errors. An instruction that returns documents, like |
False |
The number of errors is 1. MongoDB Connection is empty or doesn’t exist, the server can’t be reached or refuses the login, Use external file is checked while Filename is empty or the file can’t be read, the JSON is empty or not valid, MongoDB refuses an instruction (for example an unknown command), or Fail on write errors is checked and MongoDB reports write errors or a write concern error in its answer (for example an |
Result files |
Passed on unchanged. |
Result rows |
Passed on unchanged. |
| When an instruction has write errors, MongoDB still writes the documents before the failing one (and, for an unordered write, the documents after it). With Fail on write errors checked, the action is false and the instructions after it are not run. |
Up to Hop 2.20, text after the first JSON document or array was ignored: in {"drop": "a"}, {"drop": "b"} only the first instruction ran. Since Hop 2.21 that text makes the action false, and none of the instructions run. Put several instructions in a JSON array.
|