Odysseas Pap
10/18/2022, 1:55 PMmodel Column {
id String @id @default(cuid())
title String
projectId String
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
cards Card[]
}
model Card {
id String @id @default(cuid())
title String
description String?
columnId String
column Column @relation(fields: [columnId], references: [id], onDelete: Cascade)
}
I'm basically making a trello clone.
I'm using react-beautiful-dnd to rearrange the cards on a column, I thought the easiest way to update the database would be something like this
const result = await ctx.prisma.column.update({
where: {
id: input.colId,
},
data: {
cards: {
set: input.cards
},
},
include: {
cards: true
}
});
input.cards
has a type of Card[]
export type Card = {
id: string
title: string
description: string | null
columnId: string
}
But it doesn't work saying it got a wrong value...
How do I set the cards field with new array of card objects?Nurul
10/19/2022, 12:41 PMOdysseas Pap
10/19/2022, 2:34 PMOdysseas Pap
10/19/2022, 2:36 PMcolumn
has an 1-n relationship with cards
and I want to hard-set the cards
inside a specific column with a new array of cards.Odysseas Pap
10/19/2022, 2:37 PMset
probably isn't the write way to do this so I'm just looking for the update syntax that will help me achieve what I wantOdysseas Pap
10/19/2022, 2:37 PMVladi Stevanovic