简体   繁体   English

Prisma:使用具有非唯一字段的“where”进行更新?

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

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:在检查 Prisma ORM 中更新方法的类型时,我发现我只能包含唯一字段的 where 子句:

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?使用 Prisma 是否可以实现这一点,或者我是否需要一个单独的查询来检索实例?

In this case, you would need to use updateMany as you are using a non-unique field along with the unique one.在这种情况下,您将需要使用updateMany ,因为您正在使用非唯一字段和唯一字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM