NGRP / node-red-contrib-viseo

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

How to retrieve data by id ? #70

Closed samuelguesnier closed 6 years ago

samuelguesnier commented 6 years ago

Hi ! :) I know how to set data in the DB, but not to retrieve. What I'm trying to do is : https://image.noelshack.com/fichiers/2017/43/7/1509297841-capture-du-2017-10-29-18-23-43.png I try to get the user's data by making a get operation with his id. But I do not know why, it doesn't seem to work.

I tried some other few things but same result. Can I have some help please ? Bye :)

arimk commented 6 years ago

Hi, What you are probably missing is not setting the "value" field. You are trying to get a user by its ID, without telling which ID to search for

samuelguesnier commented 6 years ago

Hello arimk, thanks for the fast answer. I thought I was already telling the DB to search for the user ID since user.id is the user's ID. Ok so I must tell the database to search for an ID, and then in the value what ID using. I tried this but it is not working :/

https://image.noelshack.com/fichiers/2017/43/7/1509300505-capture-du-2017-10-29-19-05-06.png https://image.noelshack.com/fichiers/2017/43/7/1509300547-capture-du-2017-10-29-19-08-54.png https://image.noelshack.com/fichiers/2017/43/7/1509300615-capture-du-2017-10-29-19-08-40.png

arimk commented 6 years ago

It does not work like that. I don't really understand what you are doing in the "key" part you should have the key you are looking for (for example user.id that is sent by the microsoft bot framework) My last message was not complete. It is the key of the element you are looking. In your example it seems you are looking for the id that is a string with the value "id" which makes no sense. And in value you put the element in which you want to get the data back (for example put the user data, in "user" for this msg)

Like that

image

samuelguesnier commented 6 years ago

In my mind, I was trying to tell the DB to search for the key "id" with the value user.id . Now I understand, I must search for the key user.id and then it put it in msg.value. It works, thank you very much ;)