I want to re-create some related records on update, something like this:
db.post.update({
where: { id: 1 },
data: {
title: "The first post",
comments: {
set: [{ content: "foo"}, { content: "bar" }],
},
},
})
This is unfortunately not possible as set
only allows to reference existing comments (by using the id
). So is there another way during an update to delete all those related comments and re-create them from scratch in one transaction (and maybe on nested write)?