1

I am running the following code, where Tags is connected to an sqlite database I have set up locally. Currently I have the following code to try to pull data from the database, as a test.

console.log('debug after here.');
 
const tag = await Tags.findOne({ where: { guild: message.guild.id, channel: message.channel.id } });

console.log(' in guild: ' + message.guild.id);
console.log('out guild: ' + tag.guild);
console.log(' in chanl: ' + message.channel.id);
console.log('out chanl: ' + tag.channel);
console.log('out lpmID: ' + tag.latestPollMessageId);

The results are as follows.

debug after here.
 in guild: 228902712417189890
out guild: 228902712417189900
 in chanl: 634445907059933195
out chanl: 634445907059933200
out lpmID: 754129896791474200

As you can see, the input guild and input channel values do not match the returned guild and channel values. I peeked into the actual .sqlite file and saw the following:

database values

As you can see, the values do not represent what I'm actually getting when I run .findOne(), but I have no idea why that would be. It looks like it is generally being rounded to the nearest hundred, but I have seen some results that round down instead of up in my tests.

1 Answers1

0

In JavaScript, you can only store up to 53 bits as a number. This means the maximum number you can store in a safe integer format is 9007199254740991. (see Number.MAX_SAFE_INTEGER).

Either use id's as a string or data type as bigint in model definition

I recommend you reading this What is JavaScript's highest integer value that a number can go to without losing precision?

Sandeep Patel
  • 4,815
  • 3
  • 21
  • 37