🌐
GitHub
github.com › prisma › web › issues › 2690
BigInt Prisma type maps to `integer` postgres type · Issue #2690 · prisma/web
January 9, 2022 - The documentation specifies BigInt Prisma types have a default mapping to the integer type for postgres, but it looks like BigInts in Prisma do map to bigints in postgres. unless I'm misunderstanding 😅 Docs: https://www.prisma.io/docs/re...
Author   prisma
🌐
Prisma
prisma.io › home › postgresql › postgresql › postgresql › postgresql
PostgreSQL database connector | Prisma Documentation
Connection URL: postgresql://user:pass@host:26257/database · Built-in replication and automated failover · Horizontal scaling with no single point of failure · Key differences: ID generation example: model User { id BigInt @id @default(autoincrement()) // Uses unique_rowid() name String } For compatibility with existing databases, use sequence(): model User { id Int @id @default(sequence()) name String } Resources: CockroachDB docs • Primary key best practices ·
Discussions

Transform `BigInt` fields to `number` or `string` globally (maybe via Prisma Client extensions)?
Transform `BigInt` fields to `number` ... via Prisma Client extensions)? #20188 ... There was an error while loading. Please reload this page. Something went wrong. There was an error while loading. Please reload this page. ... Hey! I have BigInt fields in my schema (PostgreSQL) which are ... More on github.com
🌐 github.com
1
2
Casting Postgres BigInt as TS Number
Hi everyone! I'm using Prisma on my Nest JS application that connects to a Postgres Database. Some fields in this DB are all BIGINT, and Prisma returns them as JS's BigInt. I undertand that in some cases, TS Number may not be able to handle such large numbers as BigInt. More on answeroverflow.com
🌐 answeroverflow.com
September 17, 2025
PostgreSQL: `Int` type should be able to be mapped to `@db.BigInt` (int8)
Problem At the moment, the only way to use PG's int8 column type is by specifying BigInt type in the schema, which maps to Js's bigint type. But there are use cases in which we want to use ... More on github.com
🌐 github.com
35
June 9, 2021
Changing a column from `Int` to `BigInt` creates an invalid migration `Postgres`
Bug description When changing a column from Int to BigInt prisma generates an invalid migration. Example: ALTER TABLE "my_model" DROP CONSTRAINT "my_model_pkey", ALTER COLUMN "id" SET DATA TYPE BIG... More on github.com
🌐 github.com
19
March 28, 2023
🌐
Prisma
prisma.io › home › next.js › next.js › next.js › next.js
Comprehensive Guide to Using Prisma ORM with Next.js | Prisma Documentation
Data ModelWhat is introspection?PostgreSQL extensions · Prisma ClientPrisma Client · Setup and Configuration · Queries · Client Extensions · Deployment · Observability and Logging · Debugging and Troubleshooting · Special Fields and Types · Testing · Type Safety ·
🌐
GitHub
github.com › prisma › prisma › discussions › 20188
Transform `BigInt` fields to `number` or `string` globally (maybe via Prisma Client extensions)? · prisma/prisma · Discussion #20188
Now that Prisma Client extensions are out, could one write an extension that automatically transform all fields in the schema defined with BigInt to either number or string? If so, how would it look like? Beta Was this translation helpful? Give feedback. ... Hey bro, i am currently using this workaround, to fix the big int problem globally, i have it in my index.ts. (BigInt.prototype as any).toJSON = function () { return Number(this) };
Author   prisma
🌐
Answer Overflow
answeroverflow.com › m › 1417967030816079993
Casting Postgres BigInt as TS Number - Prisma
September 17, 2025 - Hi everyone! I'm using Prisma on my Nest JS application that connects to a Postgres Database. Some fields in this DB are all BIGINT, and Prisma returns them as JS's BigInt. I undertand that in some cases, TS Number may not be able to handle such large numbers as BigInt.
🌐
GitHub
github.com › prisma › prisma › issues › 7570
PostgreSQL: `Int` type should be able to be mapped to `@db.BigInt` (int8) · Issue #7570 · prisma/prisma
June 9, 2021 - prisma / prisma Public · Notifications · You must be signed in to change notification settings · Fork 2.5k · Star 47.3k · New issueCopy link · New issueCopy link · Open · Open · PostgreSQL: Int type should be able to be mapped to @db.BigInt (int8)#7570 ·
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 18532
Changing a column from `Int` to `BigInt` creates an invalid migration `Postgres` · Issue #18532 · prisma/prisma
March 28, 2023 - bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.topic: BigIntscalar type `BigInt`scalar type `BigInt`topic: broken migrationstopic: postgresql · marcus13371337 · opened · on Mar 28, 2023 · Issue body actions · When changing a column from Int to BigInt prisma generates an invalid migration.
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 28169
Support for Postgres INT8 (BIGINT) as Number in TS · Issue #28169 · prisma/prisma
September 26, 2025 - Feature Summary Allow Postgres BIGINT (INT8) to be represented as JS Number instead of BigInt. Use Cases & Problem Description When a Postgres column type is BIGINT (INT8) Prisma defaults all query results to JS BigInt. That expected sin...
Author   prisma
Find elsewhere
🌐
GitHub
github.com › prisma › prisma › issues › 13176
Allow `String` type for `Bigint` fields input create/update (postgres) · Issue #13176 · prisma/prisma
May 5, 2022 - const job = await prisma.job.create( { data: { id: '6927893654417707008', // ERROR! BigInt expected, got String }, }) But Postgres is doing fine with strings, internally converting them to BigInt.
Author   prisma
🌐
Reddit
reddit.com › r/nextjs › prisma returning a bigint for an int field via $queryraw
r/nextjs on Reddit: Prisma returning a bigint for an int field via $queryRaw
April 18, 2024 -

I am using prisma but have been using raw queries for a handful of my complex fetches while I migrate to using it fully. I'm running into an issue where, from a raw query, a field that is an Int in both my schema and database is returning as a bigint which is throwing an error when I try to serialize the result later on. The problematic field is country_prefix.

The schema model for the table that country is coming from:

model countries {

id             Int     (autoincrement()) .UnsignedInt

country_name   String .VarChar(256)

country_prefix Int    .UnsignedInt
...

The query:

const countries = await prisma.$queryRaw\`  
SELECT pc.country_prefix,  
ct.city_name,  
ct.city_prefix,

...

The object I'm getting back:

{

country_prefix: 54n,

city_name: 'Villa Mercedes',

city_prefix: '2657',

...

I have seen other people online running into this issue when executing a raw query with COUNT but I'm not using count at all, just some table joins where none of the tables have fields that use bigint. Interestingly I don't see the error when running the app via `npm run dev` but when I run a built version or deploy it to vercel it starts throwing the error. I am currently working around it by mapping the repsponse and casting the field to a number but that sucks and I'd like to know why it's happening.

If anyone has run into this before help would be much appreciated.

🌐
GitHub
github.com › prisma › prisma › issues › 6212
"number too large to fit in target type" using BigInt & PostgreSQL · Issue #6212 · prisma/prisma
March 23, 2021 - I know that Prisma maps BigInt to integer for PostgreSQL databases & thusly BigInt cannot handle numbers larger than 9223372036854775807.
Author   prisma
🌐
Medium
medium.com › @connect.hashblock › 10-prisma-postgres-moves-for-fast-queries-no-index-bloat-a4d94d33d85b
10 Prisma + Postgres Moves for Fast Queries (No Index Bloat) | by Hash Block | Medium
October 13, 2025 - By feeding Postgres simpler work and teaching Prisma to ask cleaner questions. Here are ten moves I reach for before I even think about CREATE INDEX. Offset pagination forces Postgres to count past rows. Keyset pagination uses the last seen value and a composite sort. model Order { id BigInt @id @default(autoincrement()) createdAt DateTime @default(now()) totalCents Int userId BigInt @@index([createdAt, id], map: "orders_created_id") // light, purposeful }
🌐
GitHub
github.com › prisma › prisma › issues › 19860
Allow to map `db.Decimal(X, 0)` to JS `bigint` · Issue #19860 · prisma/prisma
June 20, 2023 - kind/featureA request for a new ... very large number that could hold thousands of digits. Postgres on the other hand only supports 8 bytes for a bigint (~19 digits)....
Author   prisma
🌐
Medium
medium.com › @truongtronghai › bigint-prisma-client-and-json-stringify-b5baa569cb47
BigInt, Prisma Client, and JSON.stringify | by Truong Trong Hai | Medium
September 5, 2024 - When you use a BigInt field in your Prisma schema, both your database (if it supports BigInt) and Prisma Client recognize it. Prisma Client even returns a genuine JavaScript BigInt for that field.
🌐
Scribd
scribd.com › document › 829006134 › prisma-types
Prisma MongoDB BigInt Support Guide | PDF | Postgre Sql | Databases
The document provides a comprehensive overview of various special fields and types used with Prisma Client, including Decimal, BigInt, Bytes, DateTime, and JSON fields. It includes code examples for creating records with these types and notes on specific considerations, such as serialization ...
🌐
Medium
medium.com › @tbreijm › bigint-identifiers-when-using-prisma-and-inngest-with-js-ts-f78ac31e1e7a
BigInt identifiers when using Prisma and Inngest with TypeScript | by Tony Reijm | Medium
January 29, 2024 - type DBUser = { id: bigint } export const addProfile = inngest.createFunction( { id: "function-id"}, { event: "event-id" }, async ({ event, step }) => { const user: DBUser = await step.run( "get-user", async (email: string) => prisma.users....
🌐
Reddit
reddit.com › r/postgresql › what postgres datatype for monetary values in a nest.js microservice architecture?
r/PostgreSQL on Reddit: What Postgres datatype for monetary values in a Nest.Js microservice architecture?
September 1, 2023 -

I am currently working on a microservice architecture using Nest.Js and PostgreSQL using Prisma as the ORM, and I am facing challenges with handling monetary values. Initially, I considered using the BigInt data type to represent monetary values in the smallest currency unit (MicroUSD), where 1 million equals $1. This approach worked well when sending BigInt data from Microservice 1 to Microservice 2, as the BigInt gets serialized to a string by Microservice 1's custom serializer, and Microservice 2 then transforms it back to a BigInt using a custom decorator in its DTO (called TransformAndValidateIsBigInt, that's a mouthful).

However, I encountered issues when Microservice 2 sends back a field with a BigInt in it. Although it correctly serializes it into a BigInt when sending it back, Microservice 1 receives a string since there's no way to transform it using decorators on incoming data. And it would obviously be impossible to know what strings were originally BigInts.

One solution I've considered is to create a ResponseDto and transform the raw data using the plainToClass function from class-transformer manually. However, this seems like a significant change and I'm not sure if it's the best approach.

I'm now wondering if I should abandon the BigInt approach altogether, despite its benefits over floating-point numbers. I'm also considering other PostgreSQL data types that might be more suitable for handling monetary values in this context.

Could anyone provide insights or recommendations on the best PostgreSQL data type to use for monetary values in a Nest.Js microservice architecture, considering these serialization and deserialization challenges?

🌐
Readthedocs
prismadb.readthedocs.io › en › 0.4.4 › data-types
Data Types - Prisma/DB Documentation
Skip to content · Data Types · MySQL · SQL Server · length values for SQL Server datatypes can also be defined as MAX · PostgreSQL