Prisma: Update using "where" with non-unique fields?

Viewed 2908

When checking out the typings for the update method in Prisma ORM, I found that I can only include a where clause for unique fields:

return this.prisma.publication.update({
    data,
    where: {id},
});

I'd love to combine this with authentication and do something like:

return this.prisma.publication.update({
    data,
    where: {id, owner: user.id}, <-- Authorisation
});

Is this at all possible with Prisma or do I need a separate query for this that retrieves the instance?

1 Answers

In this case, you would need to use updateMany as you are using a non-unique field along with the unique one.

Related