Home > database >  MySQL In NodeJS is grabbing IDs from a database but it's changing the last 2 digits of it to 00
MySQL In NodeJS is grabbing IDs from a database but it's changing the last 2 digits of it to 00

Time:01-19

I'm having troubles with MySQL for node, when I see the IDs on the DB, they look fine, but when I grab it with the MySQL (code below) the last 2 digits are replaced by 0, any ideas on what's happening & how to solve it? I also will attach a picture of the database data & settings Settings Data

dbPool.getConnection((err, con) => {
        if (err) throw err
        con.query(`SELECT * FROM node_1 WHERE gid`, (err, rows:guildData[]) => {
            if(err) throw err
            rows.forEach(row => {
                client.dataGuilds.set(`${row.gid}`, row)
                console.log(row.gid)
            })
        })
        con.release()
})

CodePudding user response:

Solved, instead of turning a bigint into a string, just store it as an string

CodePudding user response:

The problem is that DB bigint exceeds Number.MAX_SAFE_INTEGER. You can use BitInt(x) to convert:

const x = BigInt(928711151708167415);
console.log(x);
  •  Tags:  
  • Related