PrismaJs when update how to delete all connections?
Unanswered
Selkirk Rex posted this in #help-forum
Selkirk RexOP
export async function updateArticle(id: string, article: z.infer<typeof ArticleSchema>) {
await prisma.article.update({
where: { id },
data: {
title: article.title,
content: article.content,
heading: article.heading,
language: article.language,
picture: article.picture,
tags: {
deleteMany: {},
connectOrCreate: article.tags.map((tag) => ({
where: { name: tag },
create: { name: tag }
}))
}
}
});
}2 Replies
Selkirk RexOP
when user updates article he can delete all tags but keep some of them
how to delete old ones and add the ones that is not added to article