问题
I have an application written in Node JS and uses the Sequelize js ORM library to access my database which is MySql.
My problem is that I have a column in my db which is BIGINT and when the value of it is large I get wrong values when I retrieve it.
for example when the value in database is: 10205918797953057
I get 10205918797953056
when I get it using sequelize.
I tried using big-integer
library but I had no luck.
any advice is welcomed.
P.S: I can't change the datatype to VARCHAR.
回答1:
You should enable supportBigNumbers
and possibly bigNumberStrings
on the mysql module: https://github.com/felixge/node-mysql#connection-options
new Sequelize(..., {
dialect: 'mysql',
dialectOptions: {
supportBigNumbers: true
}
});
来源:https://stackoverflow.com/questions/28433139/sequelize-js-with-big-integers