Indxgo
06/11/2021, 9:26 PMArgument where of type AccountWhereUniqueInput needs exactly one argument, but you provided id and authorization. Please choose one. Available args:
I don't know how to fix itjanpio
Indxgo
06/11/2021, 9:57 PMjanpio
account queries you posted above?janpio
account model look like?Indxgo
06/11/2021, 9:59 PMmodel Account {
id Int @default(autoincrement()) @id
username String @unique @db.VarChar(35)
email String @unique @db.VarChar(75)
password String @db.VarChar(100)
authorization String @unique @db.VarChar(100)
ip String @default("127.0.0.1") @db.VarChar(150)
type Int @default(1)
@@map("accounts")
}Indxgo
06/11/2021, 10:02 PMArgument where of type AccountWhereUniqueInput needs exactly one argument, but you provided id and authorization. Please choose one. Available args:
type AccountWhereUniqueInput {
id?: Int
username?: String
email?: String
authorization?: String
}janpio
Indxgo
06/11/2021, 10:04 PMawait prisma.account
.findFirst({
where: {
id: user.id,
authorization: user.authorization,
},
})Indxgo
06/11/2021, 10:04 PMjanpio
const user1 = await prisma.account.findFirst({
where: {
id: 1,
authorization: "foo"
}
})
console.log(user1)janpio
const user1 = await prisma.account.findMany({
where: {
id: 1,
authorization: "foo"
}
})
console.log(user1)Indxgo
06/11/2021, 10:22 PMthen and the problem is this code:
await prisma.account
.delete({
where: {
id: user.id,
authorization: user.authorization,
},
})
.then(() => {
req.session.destroy();
addResponse(false, null, "Account deleted.");
res.status(200).json(response);
})
.catch(() => {
addResponse(true, "Query failed, please try again.");
res.status(200).json(response);
});Indxgo
06/11/2021, 10:22 PMjanpio
Indxgo
06/11/2021, 10:23 PMIndxgo
06/11/2021, 10:23 PMIndxgo
06/11/2021, 10:23 PMjanpio
delete needs to uniquely identify a database entryjanpio
Indxgo
06/11/2021, 10:24 PMIndxgo
06/11/2021, 10:24 PMjanpio
@@unique([id, authorization])janpio
janpio
Indxgo
06/11/2021, 10:27 PMSascha Ormanns
06/14/2021, 2:11 PMjanpio
Sascha Ormanns
06/14/2021, 2:55 PMjanpio
Sascha Ormanns
06/14/2021, 2:58 PMjanpio
Sascha Ormanns
06/14/2021, 2:59 PMjanpio
janpio
many methods that are not limited to 1 entry being affected.Sascha Ormanns
06/14/2021, 3:05 PMjanpio
janpio
Sascha Ormanns
06/14/2021, 3:32 PMmany methods do not return the affected "entities". So I would have to do an additional query. No worries. Thanks for your help @janpiojanpio
janpio
Sascha Ormanns
06/14/2021, 3:40 PMjanpio
janpio
janpio
Sascha Ormanns
06/16/2021, 12:01 PM