NGRP / node-red-contrib-viseo

Node-RED nodes OpenSourced by VISEO Technologies
Apache License 2.0
227 stars 83 forks source link

Viseo not adding data to the DB #67

Closed samuelguesnier closed 6 years ago

samuelguesnier commented 6 years ago

Hey :)

I connected the channel Viseo DB "NoSQL" to my mongoDB. It connects to db successfully

(I ACCESS [conn9] Successfully authenticated as principal samuel on user ).

But it won't set data in the DB. I have no error messages Here's what is in the channels :

https://image.noelshack.com/fichiers/2017/42/4/1508423099-capture-du-2017-10-19-16-24-40.png

https://image.noelshack.com/fichiers/2017/42/4/1508423099-capture-du-2017-10-19-16-24-02.png

Have a nice day

Klervix commented 6 years ago

Hey Samuel ! :) Indeed, our documentation wasn't very clear here... (I will correct this asap) First of all, you have to make sure that the file (yourdb.db, as you wrote in the config field) was created in your folder. Then, you have to imagine (another correction to do, oops), that the "Key" and "Value" fields are "msg." fields, so you don't have to precise it in the node. So before your DB Node, set a "msg.key" with your key, "msg.value" with your value, and in the DB Node, set "Key" as "key", and "Value" as "value". Like this:

image

Hope it will fix your problem, and so sorry for this mistake! Have a nice day :)

samuelguesnier commented 6 years ago

Thank you very much Klervi ! ;) Now I better understand how it works. So I tested what you told me, and it sucessfully creates the document test.db However, although it creates the database "test.db" in bot/data, when I run "vim test.db" there is nothing in it. Is it normal ?

Klervix commented 6 years ago

Well, it depends on your value. If you try to set a string, it will fail. Try to set your msg.value to a json object (for example : { "city" : "Amsterdam"}). It should work :)

samuelguesnier commented 6 years ago

Ho cool ! Thanks :+1:

samuelguesnier commented 6 years ago

I have few more little questions :p Why setting a string to the value fails ? I imagine it is because it's a NoSQL database working w/ BSON, and it must have a key and a value, like your example {"city": "Amsterdam"}. But it would be maybe easier to set "city" to msg.key and "Amsterdam" to msg.value. I tested and it is not working. (But when I set msg.value to { "city" : "Amsterdam"}, it is working) .

Another question : In this example https://raw.githubusercontent.com/NGRP/node-red-contrib-viseo/master/node-red-contrib-botbuilder/doc/node_start.jpg What is written in the key and value fields ?