let rows = db.prepare("SELECT COUNT(*) FROM table").get();
Returns the object
{ 'COUNT(*)': 2 }
I am not sure how to read that as
console.log(rows.COUNT(*));
Returns
SyntaxError: Unexpected token *
let rows = db.prepare("SELECT COUNT(*) FROM table").get();
Returns the object
{ 'COUNT(*)': 2 }
I am not sure how to read that as
console.log(rows.COUNT(*));
Returns
SyntaxError: Unexpected token *
{ 'COUNT(*)': 2 }
Since COUNT(*)
is a key. You can access it directly by using Bracket notation
console.log('No of rows ', row['COUNT(*)']); //logs 2
I found the solution is
Object.values(rows);
It will return a length 1 array with just the number
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Object/values