FLYNNLABAboutMeCodingActivityStudy 2024초등수학
nodejs mysql BIGINT 처리
nodejs

기존 레거시 시스템을 nodejs 로 랩핑하고 있는데 mysql 내에서 BIGINT 타입으로 키를 사용하고 있었다.

문제는 javascript 특성상 BIGINT를 표현하지 못한다 ㅠㅜ(http://ecma262-5.com/ELS5_HTML.htm#Section_8.5)

막 삽질을 하고 있었는데 다행이 BIGINT를 String으로 처리해주는 옵션이 있어서 공유한다.

var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'me',
  password : 'secret',
  supportBigNumbers : true,
  bigNumberStrings : true
});

https://github.com/felixge/node-mysql

참고로 ORM 프레임워크(http://sequelizejs.com/docs/latest/usage#block-4-line-29)도 이러한 옵션을 잘 지원해준다^^