Server
Solution for NodeJS MYSQL query result buffer
void
2020. 3. 13. 10:00
const totalCount = await connection.query(data.totalCount);
console.log(totalCount);
sql문을 작성하니 return 값이 아래와 같이 버퍼와 함께 왔음
"totalCount":
[[{"count":11}],
[{"_buf":{"type":"Buffer","data":[1,0,0,1,1,27,0,0,2,3,100,
101,102,0,0,0,5,99,111,117,110,116,0,12,63,0,21,0,0,0,8,129,
0,0,0,0,5,0,0,3,254,0,0,35,0,3,0,0,4,2,49,49,5,0,0,5,254,0,0,35,0]},
"_clientEncoding":"utf8","_catalogLength":3,"_catalogStart":10,"_schemaLength":0,
"_schemaStart":14,"_tableLength":0,"_tableStart":15,"_orgTableLength":0,
"_orgTableStart":16,"_orgNameLength":0,"_orgNameStart":23,"characterSet":63,
"encoding":"binary","name":"count","columnLength":21,"columnType":8,"flags":129,
"decimals":0}]],
그래서
const totalCount = await connection.query(data.totalCount);
console.log(totalCount[0]);
0 번째값만 가져옴