per
08/20/2022, 6:04 PMstring
and not a date
.
I know I can create a New Date()
on the frontend but my types are messing up because it’s set to Date
-type in the schema but it’s actually a string in my code. What is the correct way to handle this?Nurul
08/22/2022, 7:34 AMnew Date('2020-01-01T00:00:00.000Z')
So considering this model:
model User {
id String @id @default(cuid())
firstName String
lastName String
email String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userTime DateTime
}
You could insert the record like this:
const createUser = await prisma.user.create({
data: {
email: '<mailto:test@test.com|test@test.com>',
firstName: 'John',
lastName: 'John',
createdAt: new Date(),
userTime: new Date('2020-01-01T00:00:00.000Z'),
},
});
per
08/22/2022, 7:38 AMNurul
08/30/2022, 12:55 PM