I have this schema ```model Column { id ...
# orm-help
o
I have this schema
Copy code
model 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
Copy code
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[]
Copy code
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?
👀 1
n
Hello @Odysseas Pap 👋 Set should indeed override the value of relations. Can you share the exact error message that you get? Also can you please share which database and Prisma version you are using so that I can try to replicate this locally?
o
My code has change somewhat and I would have to rollback to see the exact error message but it said "Got a wrong value, expected only an id". Which made me understand that set only updates the relations between models but I want to set the entire record but keep the relations
Basically my
column
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.
set
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 want
I hope I made my problem clear for you @Nurul Thanks for the taking the time on this
v
👋 Hello @Odysseas Pap - this is is just to let you know that we haven't forgotten about this! @Nurul is still actively investigating it and we'll get back to you asap. Thank you for the patience! 🙏 😊