개발모음집

Solution for NodeJS MYSQL query result buffer 본문

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 번째값만 가져옴

'Server' 카테고리의 다른 글

pm2 logrotate 에 대해서  (0) 2021.02.18
Docker로 nginx, netty 설치  (0) 2020.11.10
리눅스 스왑메모리 추가하는 방법  (0) 2020.03.11
postman api를 web으로 출시하기  (0) 2020.02.13
iptables open port  (0) 2020.01.17