我正在构建一个ReactJS/Node.js世界杯比分预测Web应用程序,我偶然发现了一个奇怪的问题。
我有一个“seed.js”文件,其中包含了世界杯每场比赛的数据,每场比赛都是这样一个对象:
{
"gameTime": "2022-11-30T15:00:00Z",
"homeTeam": "tun",
"awayTeam": "fra",
"groupLetter": "d",
},
(我只放了一个游戏作为参考--还有47个类似的游戏)。
下面是Prisma模式:
generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialIntegrity"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
referentialIntegrity = "prisma"
}
model User {
id String @id @default(cuid())
name String
email String @unique
username String @unique
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
guesses Guess[]
}
model Game {
id String @id @default(cuid())
homeTeam String
awayTeam String
gameTime DateTime
groupLetter String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
guesses Guess[]
@@unique([homeTeam, awayTeam, gameTime, groupLetter])
}
model Guess {
id String @id @default(cuid())
userId String
gameId String
homeTeamScore Int
awayTeamScore Int
user User @relation (fields: [userId], references: [id])
game Game @relation (fields: [gameId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([userId, gameId])
}
但是,当我将这些游戏植入数据库时,每个游戏对象的情况如下:
{
"id":"cladepd2o0011wh7ca47fo06f",
"homeTeam":"tun",
"awayTeam":"fra",
"gameTime":"2022-11-30T15:00:00.000Z",
"createdAt":"2022-11-12T04:07:07.632Z",
"updatedAt":"2022-11-12T04:07:07.632Z"
}
没有“groupLetter”参数!这是一个关键参数,因为我将其用作过滤器,所以我的应用程序一次只显示一组游戏。然后,当它试图按组字母获取游戏时,我得到以下错误:
[GET] /games?groupLetter=a
01:12:46:96
PrismaClientValidationError: Unknown arg `groupLetter` in where.groupLetter for type GameWhereInput.
at Document.validate (/var/task/node_modules/@prisma/client/runtime/index.js:29297:20)
at serializationFn (/var/task/node_modules/@prisma/client/runtime/index.js:31876:19)
at runInChildSpan (/var/task/node_modules/@prisma/client/runtime/index.js:25100:12)
at PrismaClient._executeRequest (/var/task/node_modules/@prisma/client/runtime/index.js:31883:31)
at async PrismaClient._request (/var/task/node_modules/@prisma/client/runtime/index.js:31812:16)
at async list (file:///var/task/api/games/index.js:14:23)
at async bodyParser (/var/task/node_modules/koa-bodyparser/index.js:95:5)
at async cors (/var/task/node_modules/@koa/cors/index.js:108:16) {
clientVersion: '4.4.0'
}
我已经尝试过通过PlanetScale删除“Game”表并再次推送它,但没有效果。我只是不明白为什么“groupLetter”从prod数据库中丢失。
哦,在本地,一切都很好(应用程序显示的游戏按组排序,正是它应该是)。
希望我没有把它弄得更混乱。你们能帮帮我吗?
1条答案
按热度按时间bq8i3lrv1#
没关系......我意识到,在通宵在屏幕前研究和做了大量的试验和错误,我没有重做
npx prisma generate
程序。现在问题解决了。