JS numbers doesn't support 64 bit integers. There are libraries that offer support like https://www.npmjs.com/package/big-integer
I am trying to store nanoseconds in the database as a BIGINT, but sequelize converts it to a javascript number when it reads it from the database (mysql). This truncates the value to fit inside javascript's range.
Easy way for sequelize to support this is to return the number as a javascript string, if the value won't fit inside the javascript number.
You will notice that the mysql driver does not cast BIGINT into a number, due to this issue.
You can enable the node mysql options for bigint support like so:
new Sequelize(..., {
dialectOptions: {
supportBigNumbers: true,
bigNumberStrings: true
}
});
K thanks. It might be useful to document this near the BIGINT documentation.
Most helpful comment
You can enable the node mysql options for bigint support like so: