# Injecting multiple JSON objects in a database

**URL:** <https://discourse.nodered.org/t/injecting-multiple-json-objects-in-a-database/31842>\
**Category:** General\
**Created:** [21 August 2020 15:20 UTC](https://discourse.nodered.org/t/injecting-multiple-json-objects-in-a-database/31842 "2020-08-21T15:20:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SinZapatillas](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@SinZapatillas](https://discourse.nodered.org/u/SinZapatillas)\
**Post date:** [21 August 2020 15:20 UTC](https://discourse.nodered.org/t/injecting-multiple-json-objects-in-a-database/31842/1 "2020-08-21T15:20:48Z")

</div>

Hello!

I have a data logger in a device that captures dat in an SD at a 100Hz data rate from 6 sensors. Every 0.01s I collect the data and create a JSON object that looks like this:

> lectura = {  
> "ID" : 1,  
> "Fuerza" : [15.23,17.72],  
> "Velocidad" : [5,4.8],  
> "timestamp" : "19-08-2020T16:00:13Z",  
> "milis" : 12563452  
> }

Once the device finds WiFi, it sends the info to my app, which I am managing with node-red. Thing is, its such a big amount of data that I would like to send it in packets of 50 or 100 objects at once. But once I recieve the data in Node-Red, I don´t know how to split every object from one another and inject it into the data base.

The flow is the following:

```auto
[{"id":"7b63b1a9.f2278","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"604ee5e2.10df3c","type":"debug","z":"7b63b1a9.f2278","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1640,"y":400,"wires":[]},{"id":"3c7e18e4.a04d48","type":"inject","z":"7b63b1a9.f2278","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"{\"ID\":1,\"Fuerza\":[15.23,17.72],\"Velocidad\":[5,4.8],\"timestamp\":\"19-08-2020T16:00:13Z\",\"milis\":12563452} {\"ID\":1,\"Fuerza\":[15.23,17.72],\"Velocidad\":[5,4.8],\"timestamp\":\"19-08-2020T16:00:13Z\",\"milis\":12563452} {\"ID\":1,\"Fuerza\":[15.23,17.72],\"Velocidad\":[5,4.8],\"timestamp\":\"19-08-2020T16:00:13Z\",\"milis\":12563452} {\"ID\":1,\"Fuerza\":[15.23,17.72],\"Velocidad\":[5,4.8],\"timestamp\":\"19-08-2020T16:00:13Z\",\"milis\":12563452} {\"ID\":1,\"Fuerza\":[15.23,17.72],\"Velocidad\":[5,4.8],\"timestamp\":\"19-08-2020T16:00:13Z\",\"milis\":12563452} {\"ID\":1,\"Fuerza\":[15.23,17.72],\"Velocidad\":[5,4.8],\"timestamp\":\"19-08-2020T16:00:13Z\",\"milis\":12563452} {\"ID\":1,\"Fuerza\":[15.23,17.72],\"Velocidad\":[5,4.8],\"timestamp\":\"19-08-2020T16:00:13Z\",\"milis\":12563452} {\"ID\":1,\"Fuerza\":[15.23,17.72],\"Velocidad\":[5,4.8],\"timestamp\":\"19-08-2020T16:00:13Z\",\"milis\":12563452} {\"ID\":1,\"Fuerza\":[15.23,17.72],\"Velocidad\":[5,4.8],\"timestamp\":\"19-08-2020T16:00:13Z\",\"milis\":12563452} {\"ID\":1,\"Fuerza\":[15.23,17.72],\"Velocidad\":[5,4.8],\"timestamp\":\"19-08-2020T16:00:13Z\",\"milis\":12563452}","payloadType":"jsonata","x":330,"y":300,"wires":[["d036c01a.fe472"]]},{"id":"d036c01a.fe472","type":"function","z":"7b63b1a9.f2278","name":"","func":"var id = msg.payload.ID;\nvar Fi = msg.payload.Fuerza[0];\nvar Fd = msg.payload.Fuerza[1];\nvar Vi = msg.payload.Velocidad[0];\nvar Vd = msg.payload.Velocidad[1];\nvar time = msg.payload.timestamp;\nvar mili = msg.payload.milis;\n\nmsg.topic = \"INSERT INTO Sensores(ID_and_s,V_izq,V_der,F_izq,F_der,tiempo_mili)\" + \"VALUES (\"+id+\",\"+Vi+\",\"+Vd+\",\"+Fi+\",\"+Fd+\",\"+mili+\")\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":520,"y":300,"wires":[["13d41800.259e08"]]},{"id":"13d41800.259e08","type":"mysql","z":"7b63b1a9.f2278","mydb":"2becde9d.a8a7b2","name":"","x":720,"y":300,"wires":[["4d23b71e.34de58"]]},{"id":"4d23b71e.34de58","type":"debug","z":"7b63b1a9.f2278","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":380,"wires":[]},{"id":"2becde9d.a8a7b2","type":"MySQLdatabase","z":"","name":"","host":"127.0.0.1","port":"3306","db":"I-Walker","tz":""}]

```

Is there anyway? Or is just better to send them one by one.. The sending rate doesn´t need to be 100Hz as Ive already stored the timestamp.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 October 2020 15:20 UTC](https://discourse.nodered.org/t/injecting-multiple-json-objects-in-a-database/31842/2 "2020-10-20T15:20:49Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
