Error

I get a error on my data when i create a user and i saw some blogs where its cus i have information i have mandated to setup but I dont understand what it is since i basically made everything possibly optional. This is the error ype '{ email: string; balance: number; username: string; }' is not assignable to type '(Without<UserCreateInput, UserUncheckedCreateInput> & UserUncheckedCreateInput)
const user = await prisma.user.create({
data:{
balance : 0.00,
username : "arshbakh",
}
})


model Bet {
id Int @id @default(autoincrement())

placedDate DateTime? @default(now())
updateDate DateTime? @updatedAt
team1 String?
team2 String?
amount Float?
winningAmount Float?
status String?
odds Float?

//many bets to one user
user User? @relation(fields: [userId], references: [id])
userId Int?

//many bets to one agent
agent Agent? @relation(fields: [agentId], references: [id])
agentId Int?
}
const user = await prisma.user.create({
data:{
balance : 0.00,
username : "arshbakh",
}
})


model Bet {
id Int @id @default(autoincrement())

placedDate DateTime? @default(now())
updateDate DateTime? @updatedAt
team1 String?
team2 String?
amount Float?
winningAmount Float?
status String?
odds Float?

//many bets to one user
user User? @relation(fields: [userId], references: [id])
userId Int?

//many bets to one agent
agent Agent? @relation(fields: [agentId], references: [id])
agentId Int?
}
whats my issue?
2 Replies
arsh.bakh
arsh.bakhOP2mo ago
solved
Nurul
Nurul2mo ago
There shouldn't be any necessity to make fields optional. I see that you were able to resolve the issue 👍 Let us know in case you need any help in understanding Prisma query behaviour.
Want results from more Discord servers?
Add your server