Home > Software engineering >  Is there any way to explicitly declare int32 in schema in Prisma for MongoDB?
Is there any way to explicitly declare int32 in schema in Prisma for MongoDB?

Time:05-31

I did an introspection of a MongoDB from Prisma using the command 'prisma db pull'. This detected all number fields as integers (both long and int) and created the following entry in prisma.schema:

Index                       Int // Here I search for something like 'Int32'

To enable compatibility with 32bit applications I am currently looking for a way to explicitly declare the Int fields as 32bit integers - so far without success. No schema or similar is used in the database yet.

The datatypes for numeric datatypes in MongoDB with Prisma are described here

Does anyone know a way to declare this explicitly?

Thanks in advance!

CodePudding user response:

Declaring a column as Int would by default mean that it's stored as 32bit integers. If you define a column as BigInt then those integers would be stored as 64bit integers.

Here's a reference of mapping between Prisma and MongoDB types: Reference

CodePudding user response:

In addition to Nurul Sundarani helpful hint, I found some helpful information in Prisma's documentation here.

There is the possibility to explicitly refer to the Int datatype of MongoDB - in schema.prisma this must be entered as follows:

Index                       Int @db.Int // Explicit use of the 32bit integer of MongoDB
  • Related