Prisma datamodel.prisma 在模型上给出了几个错误
Prisma datamodel.prisma gives several errors on model
我正在学习使用 GraphQl 和 prisma,我正在学习本教程 --> https://www.howtographql.com/graphql-js/4-adding-a-database/
我遵循了它,但是将 Link 更改为具有名称字段和成本的服务(现在这是一个字符串),我制作了一个 datamodel.prisma 文件,看起来像这个
type Service {
id: ID! @id
createdAt: DataTime! @createdAt
updatedAt: DataTime! @updatedAt
name: String!
cost: String!
}
但它给了我这个错误,我不明白它应该是正确的语法吗?:
Errors:
Service
× The field `createdAt` has the type `DataTime!` but there's no type or enum declaration with that name.
× The field `updatedAt` has the type `DataTime!` but there's no type or enum declaration with that name.
× The relation field `createdAt` must specify a `@relation` directive: `@relation(name: "MyRelation")`
× The relation field `updatedAt` must specify a `@relation` directive: `@relation(name: "MyRelation")`
× Fields that are marked as `@createdAt` must be of type `DateTime!` or `DateTime`.
× Fields that are marked as @updatedAt must be of type `DateTime!` or `DateTime`.
我不确定为什么我的数据模型会出现这些错误,谁能帮我解决这个问题
您打错了 -- 是 DateTime
,而不是 DataTime
。
我正在学习使用 GraphQl 和 prisma,我正在学习本教程 --> https://www.howtographql.com/graphql-js/4-adding-a-database/
我遵循了它,但是将 Link 更改为具有名称字段和成本的服务(现在这是一个字符串),我制作了一个 datamodel.prisma 文件,看起来像这个
type Service {
id: ID! @id
createdAt: DataTime! @createdAt
updatedAt: DataTime! @updatedAt
name: String!
cost: String!
}
但它给了我这个错误,我不明白它应该是正确的语法吗?:
Errors:
Service
× The field `createdAt` has the type `DataTime!` but there's no type or enum declaration with that name.
× The field `updatedAt` has the type `DataTime!` but there's no type or enum declaration with that name.
× The relation field `createdAt` must specify a `@relation` directive: `@relation(name: "MyRelation")`
× The relation field `updatedAt` must specify a `@relation` directive: `@relation(name: "MyRelation")`
× Fields that are marked as `@createdAt` must be of type `DateTime!` or `DateTime`.
× Fields that are marked as @updatedAt must be of type `DateTime!` or `DateTime`.
我不确定为什么我的数据模型会出现这些错误,谁能帮我解决这个问题
您打错了 -- 是 DateTime
,而不是 DataTime
。