Addressing an object within an array

Sorry for the basic question but I having some problems extrating my "count" as an integer from my payload when it comes back looking like this (result of an SQL query).

image

I tried with a function node and this code:

// Stores the result of the SQL query locally (is the connecting device registered?)
//var arrResult = msg.payload
var registered = msg.payload[0];
msg.payload = registered;
return msg;

However, I get the following on the debug console:

image

Cheers!

Sort you sql query out
SELECT count(*) AS myCount FROM table;
then you will get a friendly name format

or use msg.payload[0]["count(*)"]

1 Like

Perfect, thanks so much!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.