CNode

mysql处理BIGINT里面的一个坑

Hhexie发布于13 年前最后回复13 年前1 回复44382 浏览0 收藏

发现bigint数据,读取的时候,被约份了,后来查一下数据模块,发现这样就可以完美解决,分享一下

supportBigNumbers: When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option (Default: false).

var connection = mysql.createConnection({ host : 'example.org', user : 'bob', password : 'secret', supportBigNumbers: true });

PS:我是被迫用bigINT的,能不用就不用,bigint其实是很不合理的,无奈接入的API的数据类型是bigint,就好默默流泪了。

查看回复

回复 (1)

S
sumory#1·13 年前

嗯,如果后端是long(bigint)的数字类型,传到前端js时就会被js给约掉,因为js里的number有最大值限制。参考这篇:http://cnodejs.org/topic/4fb3722c1975fe1e132b5a9a

参与回复
登录后即可参与回复。登录