Thursday 20 April 2017

Access a String within "RawDataPacket" (npm mySQL response)

I did this Query using mysql npm node package :

SELECT SUM(product_sales), department_name FROM products GROUP BY department_name

My results is an array with content looking like this :

RowDataPacket { 'SUM(product_sales)': 0, department_name: 'Art' }

I would like to access 'SUM(product_sales)' doing something like res[0].SUM(product_sales) but it won't work (while it does if I do res[0].department_name).

What should I do?



via Samson Lewin

No comments:

Post a Comment