Does anybody here using BigInt with Prisma and Pos...
# prisma-client
a
Does anybody here using BigInt with Prisma and Postgres DB? How do you handle it. I would like to get a number for the BigInt Postgres field, but it uses the BigInt in generated models. It’s not handy. The problem with Int is the really small max value in Postgres. So right now we are restricted to the +2,147,483,647. Thats not that much. Any advices how to deal with it?
1
a
Hi Andreas 👋🏾 A workaround when working with BigInt values is serializing the value. Here’s how you would do so:
Copy code
JSON.stringify(
  this,
  (key, value) => (typeof value === 'bigint' ? value.toString() : value) // return everything else unchanged
)
In case you get stuck, you can check out the docs on working with BigInts
a
Thx for reply, but thats very cumbersome. We have to do it after each Prisma call in all out services. Why not to configure the type mapping BigInt (in Postgres) -> number (in TypeScript)