The answer by Jan Aagaard Meier is correct and works, But there are few things to consider.
According to Sequelize Docs (connection-options):
supportBigNumbers
: When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option (Default: false).
bigNumberStrings
: Enabling both supportBigNumbers
and bigNumberStrings
forces big numbers (BIGINT and DECIMAL columns) to be always returned as JavaScript String objects (Default: false
). Enabling supportBigNumbers
but leaving bigNumberStrings
disabled will return big numbers as String objects only when they cannot be accurately represented with JavaScript Number objects(which happens when they exceed the [-2^53, +2^53] range), otherwise they will be returned as Number objects. This option is ignored if supportBigNumbers
is disabled.
So, in some cases, to handle the returned value correctly, using both
bigNumberStrings
and supportBigNumbers
might be a better option
that guarantees a string value in return.