INSERT Multiple Datarecords

Hello together,

now that I am basically able to write data to a MySQL database via webhook, I have another question.
For a better understanding briefly to the use case:
I support an animal welfare organization (poultry). Put simply: It should be recorded from how many eggs specific birds have hatched.

The data is collected via webhook on a website. Different birds can be reported per capture.
Important - the number of records is dynamic. See my example:


Muster2

How do I get ALL records into the MySQL database?
My current approach / solution would be to hardcode and limit to a maximum of 10 records.
I hope that there is a simple and better solution here as well.

I thank in advance!

Hello @Azathoth

So probably we can use loop, but I don’t really understand exactly how it would work. Could you provide what data/column should be made for demo data what you provide in question, please?

Thanks Simon

2 Likes

Hello, thanks for your answer. The Screenshots contains demo-data.
At its core, it concerns these values:

"fields[repeater_Rasse][id]":
"repeater_Rasse",
"fields[repeater_Rasse][title]":
"Tier",
"fields[repeater_Rasse][value][0][Rasse]":
"Amerikanische Pekingenten",
"fields[repeater_Rasse][value][0][Eingelegt]":
1,
"fields[repeater_Rasse][value][0][Farbenschlag]":
"WeiĂź",
"fields[repeater_Rasse][value][0][Befruchtet]":
1,
"fields[repeater_Rasse][value][0][GeschlĂĽpft]":
1,
"fields[repeater_Rasse][value][1][Rasse]":
"Deutsche Pekingenten",
"fields[repeater_Rasse][value][1][Eingelegt]":
1,
"fields[repeater_Rasse][value][1][Farbenschlag]":
"WeiĂź",
"fields[repeater_Rasse][value][1][Befruchtet]":
1,
"fields[repeater_Rasse][value][1][GeschlĂĽpft]":
1,

There may then be sent [value][2],[value][3],[value][n]
This data should be stored in the mySQL-Database:

Rasse Eingelegt Farbenschlag Befruchtet GeschlĂĽpft
Amerikanische Pekingenten 1 WeiĂź 1 1
Deutsche Pekingenten 1 WeiĂź 1 1

Does this help to understand better?

So I understand it like that:

Am I correct? If yes I made this:

But be aware that I rewrite it from screenshot, so there are misspells I know it :smiley:

Let me know if it is what you was looking for :slight_smile:

2 Likes

First of all, I do not want to exclude the possibility that I am misinterpreting… But…
I have checked and tested this time. Unfortunately, splitting does not work. On the one hand I get an error message… On the other hand when I look at the documentation, splitting only works if the field identifiers are identical. In the example I mean the terms name or email, see here:

But in my case I do not deliver

{
"Rasse": "American Staffordshire Terrier", 
"Cat"
}

I deliver

{
"Rasse[0]": "American Staffordshire Terrier"
}
{
"Rasse[1]": "Cat"
{

It is not called “Rasse”, it is Rasse[0]… the next field Rasse[1]
The number is unfortunately part of the name and the core problem.

So it is not a single container with a list of items, but it is several containers, which always contain only one item.
I am neither n8n-professional, nor the great developer… I would now imagine some kind of RegEx, which also includes the numbers and conjures something out of it.

No problem, could you please provide mock data what I will be able to copy and paste to n8n, please? You can do like here: https://i.imgur.com/sQ1uSwe.png

I’ll be happy to do it for you Tomorrow morning, just correct me if I am wrong at any point

  • You got some information as list
  • each “element” has some properties, in unordered way
  • all useful data are in array fields[repeater_Rasse][value]
  • one element has the following props: fields[repeater_Rasse][value][n][PROP_NAME], so:
    • fields[repeater_Rasse][value][0][Rasse]
    • fields[repeater_Rasse][value][0][Eingelegt]
    • and so on
  • some properties can be missing (i.e. some elements can have not Rasse then in db keep empty)

Anything wrong? LMK :slight_smile:

1 Like

@Azathoth have a look below:

Let me know if that works for you. And bit thanks to @MutedJam for help with conception to parse this weird JSON:)

2 Likes