Replies: 1 comment 5 replies
-
If the bigint value from the db exceeds 9007199254740991, you need to map it as string. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
At first, I thought that a
BIGINT
, orBIGSERIAL
should be mapped usingnumeric()
.In practice, querying the DB like so:
Where
discord_guild_id
is mapped withnumeric()
,Causes a type error:
I think this issue is related to this TypeScript subtlety:
So...
Should I map it as a
string()
and validate it via a RegEx as a workaround?Then I could retrieve it via the ORM, and pass it back into
BigInt
to get the correct value?(Btw: this is what other Node.js ORMs suggest to do... even if I'm unhappy with this. :/)
Btw, the JavaScript
Number
constructor is unsafe when handling big numbers:Beta Was this translation helpful? Give feedback.
All reactions