-
|
So I have an Item model defined as follows: model Item {
...
createdAt DateTime @default(now())
updatedAt DateTime
itemvariants ItemVariants[]
}
model ItemVariants {
...
createdAt DateTime @default(now())
itemId String
updatedAt DateTime
item Item @relation(fields: [itemId], references: [id])
}which I define in graphql.ts as: schema.objectType({
name: 'Item',
definition(t) {
t.model.itemvariants({
filtering: true,
ordering: true,
})
t.date("createdAt")
t.date("updatedAt")
},
})
schema.objectType({
name: 'ItemVariants',
definition(t) {
t.model.itemId()
t.model.item()
t.date("createdAt")
t.date("updatedAt")
},
})The error is being issued because in my createItem I have not specified createdAt/updatedAt attributes. How do I do this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
|
Hey @TheoMer 👋 model Item {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
itemvariants ItemVariants[]
} |
Beta Was this translation helpful? Give feedback.
-
|
Hey @ryands17 I made the amendment as recommended but VSCode is still issuing the following error: |
Beta Was this translation helpful? Give feedback.
-
|
Hi there, To keep our discussions organized and focused on the most relevant topics, we’re reviewing and tidying up our backlog. As part of this process, we’re closing discussions that have already been marked as answered but remain open. If this discussion still requires further input or clarification, feel free to reopen it or start a new one with updated details. Your contributions are invaluable to the community, and we’re here to help! For more details about our priorities and vision for the future of Prisma ORM, check out our latest blog post: https://www.prisma.io/blog/prisma-orm-manifesto. Thank you for your understanding and ongoing support of the Prisma community! |
Beta Was this translation helpful? Give feedback.
Hey @TheoMer 👋
I think the issue is because of
updatedAtand notcreatedAt.createdAtalready has a default value so it is not required to be passed while creating, but you would need to add this to the schema for automatic insertion of updated time.