P
Prisma•2mo ago
Mattèo

How to use set a relation and update in the same time rows

Hey ! I wanted to know if someone know how to achieve this :
const data: Prisma.ModuleUpdateInput = {
name: input.name,
description: input.description,
course: {
connect: {
id: input.course,
},
},
// Here is a one to many relation with Module <-* Lesson
lessons:
lessons.length > 0
? {
set: lessons.map((lessonId, index) => ({
id: lessonId,
// Adding this field don't works, only the first item is linked
order: index,
})),
}
: undefined,
}
const data: Prisma.ModuleUpdateInput = {
name: input.name,
description: input.description,
course: {
connect: {
id: input.course,
},
},
// Here is a one to many relation with Module <-* Lesson
lessons:
lessons.length > 0
? {
set: lessons.map((lessonId, index) => ({
id: lessonId,
// Adding this field don't works, only the first item is linked
order: index,
})),
}
: undefined,
}
Has anyone had this problem before, or can anyone help me? Wishing you a good day 😉
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server