Anyone know for what reason ``@updatedAt`` won't w...
# orm-help
k
Anyone know for what reason ``@updatedAt`` won't work?
r
Hey @KJReactor 👋 What’s the issue you’re facing? Could you share what DB you’re using and how is your
schema.prisma
defined?
k
Hello @Ryan.
I'm trying to have prisma enter the date for when an entity is modified. I assumed the @updatedAt directive would be automatic as the @id is but its is not working
I'm using MYSQL
r
Could you share your schema?
k
I don't have a schema.prisma file in my project. my schema is defined in a typedefs.js file as I'm using graphql
r
@updatedAt
will not work if you haven’t created a
schema.prisma
. Also whatever you define in your
schema.prisma
maps to the database when you run migrations. It has no relation whatsoever to your
typedefs.js
file.
You need to define your models as you will your tables in your
schema.prisma
file and then access it. This might be useful to have a look at.
k
Yes, my models are defined in a .graphql file
everything else works except for the @updatedAt part
r
Are you using Prisma 1 or Prisma 2? And could you share a sample repo if possible so I could reproduce it?
k
I'm using Prisma 1 for the time being. I have it only locally now.
Copy code
type Product {
  id: ID! @id
  name: String! @unique
  description: String
  date: DateTime! @createdAt
  dateUpdated: DateTime @updatedAt
  cost: Float!
  category: ProductCateg! @default(value: ELECTRONICS)
  weight: Float!
  height: Float!
  width: Float!
  rating: Float! @default(value: 0)
}
my model