Reputation: 3293
I have this node msnodesqlv8
connection and I am counting the number of records from one table. I am getting the result as { total: 26 }
and the expected result should be 26. Here is my code:
pool.connect().then(() => {
pool.request().query('SELECT count([TaskID]) as total FROM [db_test].[dbo].[tb_test]', (err, result) => {
myResults = result.recordset[0];
console.log(myResults);
})
});
Upvotes: 0
Views: 169
Reputation: 6305
As you are getting data in object form. now you have to access the object from the result.
pool.connect().then(() => {
pool.request().query('SELECT count([TaskID]) as total FROM [db_test].[dbo].[tb_test]', (err, result) => {
myResults = result.recordset[0].total;
console.log(myResults.total); // it should provides you expected result
})
});
Upvotes: 1