MongoDB write documents from an API call

I’m trying to achieve the following:
Step1: Querying an API to receive JSON Documents (restaurant delivery orders)
It looks like this (pretty good to me):

Step 2: I want to record each order individually in a Mongo database.
For this I’m iterating on the order array:
image

And then i tried to insert each document (collection ?) in a mongo collection:
-The connection is OK
-But i don’t want really to establish a data structure, as it could change (NoSql), so I have just made a text structure in which i’m placing a field from the iterator (because it does not show me a bundle). The result is that it is creating the document in Mongo, but only with one field.
Data structure:


Mongo configuration:

How to solve this so that I can have exactly what i’m querying from the API to MongoDB document.

Thanks a lot

Hey @Marck ,

Probably the best way to do this, without too much work, is to create an Array data structure that looks the same as the orders[…] output you get.
Then once you have this structure, you can map the field in the MongoDB module and just paste the array if the API in there (without the iterator).

Best way to create this structure, is to copy the JSON structure from the API as text and then place this in the JSON generator.


Creating a data structure


Mapping the array

Let me know if this helps you or if you need anything else :wink:

3 Likes