const id = /* Playlist's ID */
const videoUrl = /* Video's Url, which is its primary key */
// I want to use an array of videoUrls instead, not just one
const updatedPlaylist = await prisma.playlist.update({
where: { id },
include: { videos: { include: { video: true } } },
data: {
videos: {
upsert: {
where: {
playlistId_videoUrl: {
playlistId: id,
videoUrl: videoUrl,
},
},
create: {
addedAt: new Date(),
video: {
connect: { url: videoUrl },
},
},
update: {},
},
},
},
});
const id = /* Playlist's ID */
const videoUrl = /* Video's Url, which is its primary key */
// I want to use an array of videoUrls instead, not just one
const updatedPlaylist = await prisma.playlist.update({
where: { id },
include: { videos: { include: { video: true } } },
data: {
videos: {
upsert: {
where: {
playlistId_videoUrl: {
playlistId: id,
videoUrl: videoUrl,
},
},
create: {
addedAt: new Date(),
video: {
connect: { url: videoUrl },
},
},
update: {},
},
},
},
});