Hello Steve and afelix,
and thank you for your reply!
I am used to working with this node - but so far only with static queries. I have a rough idea what AlaSQL is in the background. Setting this up as a static query does work:
SELECT event FROM MyDB
WHERE ts = "2020.06.25 10:05:30.632"
I also created this "database" MyDB:
CREATE TABLE MyDB (ts TIMESTAMP VARCHAR(80), event VARCHAR(255));
And I have Node-RED set up to feed data into it - so the select/where query above does retrieve an event for me.
Injecting the message as an array and using msg.topic
or msg.query
(instead of message.payload
) was a good tip. I come to the same conclusion after re-reading the README. But I cannot get it to work:
object
_msgid: "255e763c.6ce1ba"
topic: array[1]
0: "2020.06.25 10:05:30.632"
payload: array[1]
0: "2020.06.25 10:05:30.632"
query: array[1]
0: "2020.06.25 10:05:30.632"
But the node does not use the message - this still gives me an empty array in return:
SELECT event FROM MyDB
WHERE ts = $0
This part I don't understand:
msg.payload = [ {id:0,t:"hello"} , {id:1,t:"bye"} ];
msg.query = "SELECT id,t FROM ? WHERE t = 'bye'; ";
return msg;
You do not have to provide your data inside the query. AlaSQL behaves like an SQL database. Node-RED fills it with data, and I can query against this "database" - just like SQLite. Of course, everything is only in memory - there is nothing persisted. In the end there is no database.
But currently, I am stuck - I think I will try solving this with SQLite instead. Maybe, dynamic queries are just broken at the moment.