Is it possible to change the type for a field only...
# orm-help
j
Is it possible to change the type for a field only for comparing it with some data? If yes then please do let me know...
r
@jignesh karamchandani 👋 In this case, you can change that type of data to compare it with the field. Would that be possible in your case?
j
In my case I want to compare dates... but in db it is Date type and I have it in iso string format
r
Yes then
new Date(isoDate)
should work when comparing right?
j
new Date returns whole string
r
You can also use an ISO String to compare. Given this schema:
Copy code
model User {
  id        Int      @id @default(autoincrement())
  createdAt DateTime @default(now())
}
I can pass in an ISO string directly to compare:
Copy code
let date = new Date().toISOString()
await prisma.user.findMany({ where: { createdAt: date } })
j
I'll try that... Thanks😇
💯 1