Sequelize js with large integers

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 that is BIGINT, and when the value of this value is large, I get the wrong values โ€‹โ€‹when I retrieve it.

for example, when the value in the database is: 10205918797953057 I get 10205918797953056 when I get it using sequelize.

I tried using the big-integer library, but I had no luck.

Any advice is welcome.

PS: I cannot change the data type to VARCHAR.

+5
source share
1 answer

You need to enable supportBigNumbers and possibly bigNumberStrings in the mysql module: https://github.com/felixge/node-mysql#connection-options

 new Sequelize(..., { dialect: 'mysql', dialectOptions: { supportBigNumbers: true } }); 
+4
source

Source: https://habr.com/ru/post/1213061/


All Articles