Nothing.
03/02/2021, 11:23 AMconst update = await prisma.categories.update({
where: {
id: req.params.id
},
data:{
status: "disabled"
}
});
I would have sent the error here but my PC is off RN.
I'm new to Prisma and I'm not sure whether I'm doing anything wrong here, please help!Ryan
03/02/2021, 11:24 AMstatus
what you’re updating a relation field?Ryan
03/02/2021, 11:25 AMNothing.
03/02/2021, 11:42 AMPrismaClientValidationError:
Invalid prisma.update() invocation in
/home/abdulrahman/Documents/Projects/intercord/backend/src/database/repositories/memberships.repository.ts:67:25
64 async deleteOneByUser(data: any) {
65 let company;
66 try {
→ 67 company = await this.update{
where: {
company_id: 1
~~~~~~~~~~
},
data: {
is_deleted: true
}
})
Unknown arg company_id in where.company_id for type membershipsWhereUniqueInput. Available args:
type membershipsWhereUniqueInput {
id?: Int
}
Nothing.
03/02/2021, 11:43 AMRyan
03/02/2021, 11:44 AMcompany_id
to id
as per the errorNothing.
03/02/2021, 12:07 PMlet membership = await prisma.memberships.findFirst({
where: {
user_id: 4,
conpany_id: 5
}
});
Then proceed to do the actual update with the above result:
await prisma.memberships.update({
where: {
id: membership.id
},
data: { /**/ }
});
But I want to just do that in one place like this:
await prisma.memberships.update({
where: {
user_id: ...
company_id: ...
},
data: { /**/ }
});
Well, I think the reason I'm getting the error I that the user_id
and company_id
aren't unique columnsRyan
03/02/2021, 12:22 PMupdateMany
in that case.
let membership = await prisma.memberships.updateMany({
where: {
user_id: 4,
conpany_id: 5
},
data: {
// data to update
}
});
Nothing.
03/02/2021, 12:46 PMMartïn
03/02/2021, 4:22 PMupdateMany
with the AND operator in that case. AND is not required if you pass the arguments to the WHERE clause as @Ryan did
let membership = await prisma.memberships.updateMany({
where:
AND: [
{user_id: 4},
{conpany_id: 5}
],
data: {
// data to update
}
});
Nothing.
03/02/2021, 6:26 PMMartïn
03/02/2021, 6:28 PMMartïn
03/02/2021, 6:29 PMMartïn
03/02/2021, 6:32 PMNothing.
03/02/2021, 8:21 PMMartïn
03/02/2021, 8:23 PMNothing.
03/02/2021, 8:23 PMNothing.
03/02/2021, 8:24 PMMartïn
03/02/2021, 8:24 PMschema.prisma
file is like 4279 LOC already.Nothing.
03/02/2021, 8:27 PMNothing.
03/02/2021, 8:30 PM