Persistence

by 00:42 0 commenti
There are a number of services providing persistence in a simple way, such as firebase or parse, just to mention few of them. Actually both of them are much more than persistence services!!!

However, for the sake of simplicity, here we will use json-db-node-red

In this simple example, the json data from openweather are stored in the JsonDB


The following is the content of the .json file under ~/.node-red/JsonDB/.json

{"prova":{"weather":"Clouds","detail":"scattered clouds","tempk":289.399,"tempc"
:16.1,"humidity":91,"maxtemp":289.399,"mintemp":289.399,"windspeed":4.23,"winddi
rection":125.006,"location":"Trevi","sunrise":1462766140,"sunset":1462817874,"cl
ouds":44,"description":"The weather in Trevi at coordinates: 41.9, 12.49 is Clou
ds (scattered clouds)."}}

As you can see the path prova, specified as a parameter of the JsonDB, is  the JSON object. To access the fields is sufficient to write msg.payload.<name of the properiy> as an example msg.payload.weather will return Clouds.

Andrea Vitaletti

Developer

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.

0 commenti:

Posta un commento

Nota. Solo i membri di questo blog possono postare un commento.