Describe the issue/error/question
How to insert the “output” from the “function node” into the mongodb insert to push the data into the database? WIth a “set node” or “without”.
Steps i want to go:
- Make API Call (working)
1.1 Response is a JSON Object (working)
1.2 Use function to extract key, value paris (working)
1.3 use set node to create a big array (not working)
1.4 use mongodb insert call to push array into mongodb (not working)
i dont understand the “set” module while working with returned data from a function.
It is adding up the fieldname into the insert call.
Image for the Workflow, as i can’t inser it accordlingy(noob? :D))
This is the “code / function node”:
This is the “set node”:
Why is the paired items now in it? I’ve read the docs but don’t need it at all.
This is the mongodb call:
I can’t access the “fieldsToInsert” Variable from the node before and also the informations in the node before (output in set node) aren’t what i want. I just want to insert the object from the "set node input.
Now i believe ive found a bug:
I cant create a key value pair in this screenshot. If i try to insert just the values i get this error, if i try to insert it by key values as “expression” like: {{ gpcode: $json[“data”][“id”] }}
isn’t working as well. I get only “gpcode” returned instead of “gpcode:4036” as id.
My question is again:
How to insert the “output” from the “function node” into the mongodb insert to push the data into the database?
Hope this is clear and specific enough.
If i try to insert the workflow, the code doesn’t resolve. I am doing something wrong.
The next thing is:
The mongodb Node has only the insert function. mongodb has something called “insertmany” to make it possible to insert several documents with one call.
Maybe you can consider this as well for future updates.
Information on your n8n setup
- n8n version: using the cloud
- Database you’re using (default: SQLite): mongodb
- Running n8n with the execution process [own(default), main]: triggering the workflow manually