Belphemur / json-db-node-red

Node-RED Node to store easilly
GNU General Public License v3.0
5 stars 17 forks source link

Help #2

Closed scargill closed 8 years ago

scargill commented 8 years ago

Maybe it is early in the morning... but I'm getting no-where.. I added json-db-node-red to my node-red installation - I took your example - and changed the location to /home/pi/timestamp and then ran the example and hit the inject. Am I supposed to be looking for a file called timestamp in /home/pi ?? I've hit refresh in win-scp - and there is no file or directory that looks anything like this.. nothing new has been added to my /home/pi directory.

Belphemur commented 8 years ago

I should rewrite the documentation of the node to be more clear about dataPath.

You can find here a better explanation of how it works: JsonDB

The basic idea is simple; a collection is your database, a simple Json File stored into your user directory.

The dataPath is the path used to store and retrieve data into that particular file. The idea is to make working with Javascript Object and Json file easier.

Example

Storing

If you store an object {name: "Antoine", lastname: "Aflalo" } at the dataPath /persons/Antoine. The module will create a new object persons with a key Antoine and value {name: "Antoine", lastname: "Aflalo" } and store it in the Json File this way:

{  
   persons:{  
      Antoine:{  
         name:"Antoine",
         lastname:"Aflalo"
      }
   }
}

Retrieving

Now imagine you want to retrieve the lastname, the dataPath to the last name is /persons/Antoine/lastname and this would return Aflalo

Is it more clear ?

scargill commented 8 years ago

Ah, right - obviously I was completely confusing that with actually saving JSON to disk - ok - crystal clear now - thanks for that.

Belphemur commented 8 years ago

Yup It does a little more than just saving it to the disk :)

You're welcome :+1: