mysql处理BIGINT里面的一个坑
发布于 11 年前 作者 hexie 43417 次浏览 最后一次编辑是 8 年前

发现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 回复

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

回到顶部