Skip to content
Advertisement

Node.js rounds my sql result. how do i prevent this?

I am requesting a bigint from my database. However, Node.js alters the value of my request, so that my program doesn’t work.

Here’s my code:

The console logs:

However, if i run the same statement in PHPmyAdmin, it looks like the following:

it returns:

Why does Node.JS round the value up and how do i prevent it?

Advertisement

Answer

This happens when the number is greater than Number.MAX_SAFE_INTEGER.

Please try following and see if you are getting expected value:

reference – https://github.com/mysqljs/mysql

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement