This is maybe a simple question... but kind of an ...
# orm-help
k
This is maybe a simple question... but kind of an obvious and clear one... Is there a way to get the
createdAt
and
updatedAt
fields in a Prisma schema? Like. I don't YET need it for my project, and I was thinking to myself "wow, if I do need this it's going to be a real embarrassment if I can't get information as simple as the updated and created at times for a row!" (nervous chuckling to self)
m
What exactly do you mean? Just define them in your db schema and query away 🙂 afaik prisma saves them internally anyways
Prisma will take care of setting the values
k
Yes yes. I've been working with Prisma nearly full-time for about 3 months now so I know how to get up all in my own app schema and shell into my db docker container and mysql query rows for myself... But I've been working with Prisma nearly full-time for about 3 months now and I am shocked I don't know how to get at it. Since the deployed prisma.graphql schema doesn't define
updatedAt
or
createdAt
values. If it's not provided by Prisma's schema, how can my app get at it? AFAIK, if I can't see it in my database Playground, I cannot get it. 😱
m
Well, correct me if I sill dont fully grasp your problem 🙂 But this is what I do to get the values:
Copy code
type Post {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
}
Then you can query them or expose them via yoga... Are we not on the same page? 🐿️
😨 1
k

https://media.giphy.com/media/3oEduVMEWIc1bOE5Ww/giphy.gif

Three months of use and I finally realize I wasn't putting
createdAt
and
updatedAt
into my datamodel.
🤭 Thanks for letting me be an idiot for a minute.
m
Enjoy 🙂 Glad I could help