martin
11/04/2020, 4:03 AMnull? For some reason, the following doesn’t work:
await prisma.path.deleteMany({
where: { AND: [{ Facilitator: { is: null } }, { User: { is: null } }] }
})Ryan
11/04/2020, 7:52 AMmodel User {
id Int @id @default(autoincrement())
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
user User? @relation(fields: [userId], references: [id])
userId Int?
}
You can find null relations like this:
const users = await prisma.user.findMany({
where: { posts: { none: { userId: { not: null } } } },
})martin
11/04/2020, 8:41 PMmodel Path {
pathId String @unique
Facilitator Facilitator? @relation("OFacilitatorToRPath")
User User? @relation("OUserToRPath")
}
model Facilitator {
Path Path @relation("OFacilitatorToRPath", fields: [pathId], references: [pathId])
pathId String @unique
}
model User {
Path Path @relation("OUserToRPath", fields: [pathId], references: [pathId])
pathId String @unique
}
How can I find `path`s that have neither a Facilitator nor a User relation?Ryan
11/05/2020, 7:40 AMconst paths = await prisma.path.findMany({
where: {
AND: [{ Facilitator: { is: null } }, { User: { is: null } }],
},
})
I added some seed data and this gives me the paths that have neither a Facilitator nor a User .martin
11/05/2020, 5:28 PM{} PrismaClientValidationError:
Invalid `prisma.path.deleteMany()` invocation in test.js:71:22
67 },
68 {
69 model: 'Path',
70 data: async () =>
→ 71 await prisma.path.deleteMany({
where: {
AND: [
{
Facilitator: {
is: null
}
~~~~~~~~~~
},
{
User: {
is: null
}
}
]
}
})
Argument Facilitator: Got invalid value
{
is: null
}
on prisma.deleteManyPath. Provided Json, expected FacilitatorRelationFilter or FacilitatorWhereInput or Null.Ryan
11/06/2020, 6:43 AM@prisma/client and @prisma/cli
Could you remove node_modules , run prisma generate and try again?martin
11/06/2020, 10:29 PM2.10.2, deleted node_modules and did prisma generate and am still getting the same issue.martin
11/06/2020, 10:30 PMProvided Json, expected FacilitatorRelationFilter or FacilitatorWhereInput or Null.martin
11/06/2020, 10:31 PMdeleteMany and not findMany?
await prisma.path.deleteMany({
where: {
AND: [{ Facilitator: { is: null } }, { User: { is: null } }]
}
})Ryan
11/07/2020, 10:15 AMRyan
11/10/2020, 8:27 AMmartin
11/13/2020, 7:56 PM