Home > Software engineering >  NODE-RED IfluxDB How do i use a variable as indentifier of a query?
NODE-RED IfluxDB How do i use a variable as indentifier of a query?

Time:11-24

I;m having a problem declaring a query on influxdb, I can't declare the identifier as a variable

I'm using the following syntax:

msg.query = "SELECT time , Temper01, Temper02, Temper03, Temper04 FROM ID WHERE time >= '2021-11-11T14:00:00Z' AND time <= '2021-11-19T14:00:00Z' tz('America/Sao_Paulo') ";

Where ID is the variable, but it only works if I put directly the value of the variable .

CodePudding user response:

You've not said where you are getting the value of ID from but assuming it's attached to a msg at msg.payload.id

You just build the string from parts:

msg.query = "SELECT time , Temper01, Temper02, Temper03, Temper04 FROM "
      msg.payload.id
      " WHERE time >= '2021-11-11T14:00:00Z' AND time <= '2021-11-19T14:00:00Z' tz('America/Sao_Paulo') ";
  • Related