Hi, I am using Prisma with Remix(TypeScript). I ha...
# orm-help
h
Hi, I am using Prisma with Remix(TypeScript). I have an issue where my
DateTime
's are returned to me as strings. I understand this is how it works when writing in TypeScript but does it mean I have to define the types on the client differently than the models I defined for Prisma? Is there a best practice for solving this? Model:
Copy code
model Review {
  id          String   @id @default(uuid())
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
  comment     String
  score       Int
  wine        Wine @relation(fields: [wineId], references: [id], onDelete: Cascade)
  wineId      String
  reviewer    WineUser @relation(fields: [userId], references: [id], onDelete: Cascade)
  userId      String
}
Query:
Copy code
let db: PrismaClient;
//Prismaclient is imported from elsewhere

...

const reviews = await db.review.findMany({
    take: 1,
  });
console.log({reviews})
Log:
Copy code
reviews: [
    {
      id: '00715d17-19ea-429d-8d04-cc0afe4f0b53',
      createdAt: '2022-09-27T18:46:08.953Z',
      updatedAt: '2022-09-27T18:46:08.953Z',
      comment: 'Mycket prisvärt. Viss fatkaraktär. Körsbärstoner. Inte så kraftigt.\n' +
        'Alk.: 13.50%',
      score: 7,
      wineId: '5b4fd795-4c82-4b78-b568-eb72754f6ab2',
      userId: '8a65f07b-6357-45b4-9fb7-c13ca989053a'
    }
  ]
1
n
Hey @Henrik Spolander 👋 PrismaClient returns all DateTime as native Date Objects as described in the reference. Are you perhaps facing this same issue described in this comment? Can you have a look?
h
Thanks for the swift response @Nurul. This is just what I was looking for. It looks to be the exact same issue. Thanks for the help!
🙏 1
💚 1
If anyone happens upon this message later: I went with the solution posted here https://github.com/prisma/prisma/discussions/5522#discussioncomment-3372645 . Worked well for my use case. 🙂
👍 2
v
Fantastic, thank you for sharing that this addressed your question and what solution you opted for this. This is extremely helpful! 💚
🫶 1