martin
11/24/2020, 5:06 PMprisma.upsert
? For example:
EventOptions: { connect: [{ eventOptionId: 'some_id' }] }
it connects the EventOptions
field to some_id
, but leaves EventOptions
other relations intact. Is there a way to replace the connections with only the some_id
connection?Ryan
11/24/2020, 5:17 PMset
should do it.martin
11/24/2020, 5:18 PMset
Ryan? Can’t find any.martin
11/24/2020, 5:18 PMdisconnect
? https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#update-an-existing-user-record-by-disconnecting-the-profile-record-its-connected-toRyan
11/24/2020, 5:21 PMconnect
with set
in the above example and that will work 🙂martin
11/24/2020, 5:22 PMmartin
11/24/2020, 5:23 PM2.11.0
.Ryan
11/24/2020, 5:25 PMmodel User {
id Int @id @default(autoincrement())
name String?
posts Post[]
createdAt DateTime @default(now())
}
model Post {
id Int @id @default(autoincrement())
user User? @relation(fields: [userId], references: [id])
userId Int?
}
I can use set
like this:
await prisma.user.upsert({
where: { id: 1 },
create: { name: 'name' },
update: { name: 'name', posts: { set: [{ id: 'something' }] } },
})
martin
11/24/2020, 5:28 PMmartin
11/24/2020, 5:28 PMset
inside the create
portion.