I am currently working on GraphQL API in Next.js project w/ TypeScript. I was following this tutorial Prisma blog. However, I am not sure how to define the createdAt and updatedAt attributes. They are defined with DateTime
type in the prisma schema. I am using MongoDB for the database.
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
Defining the type as string as string
in the nexus schema is giving type errors.
t.nonNull.string('createdAt');
Types of property 'createdAt' are incompatible.
Type 'Date' is not assignable to type 'string'.
Whereas, defining it as int
throws error Int cannot represent non 32-bit signed integer value: 1661894591365
t.nonNull.int('createdAt');
What should be the data type for createdAt and updatedAt in order to make it type safe?