Trying to update a field from the table where the table is connected with other tables also. But showing the error here. "An operation failed because it depends on one or more records that were required but not found. Record to update not found."
const deleteBook = await prisma.aca_book_list.update({
where: {
id: productId,
},
data: {
is_active: false,
}
})
await BasicResponse(res, 1, 'Book Deleted', deleteBook)
if (!deleteBook) {
await BasicResponse(res, 0, 'Book Not Found to Delete', [])
return
}
For those need to update value if it exists and insert value if it doesn't exist, you can use the Prisma upsert method - for example:
const user = await prisma.user.upsert({
where: { id: 1 },
update: { email: 'alice@prisma.io' },
create: { email: 'alice@prisma.io' },
});