gpt4 book ai didi

node.js - Prisma:使用具有非唯一字段的 "where"进行更新?

转载 作者:行者123 更新时间:2023-12-02 18:45:10 24 4
gpt4 key购买 nike

在检查 Prisma ORM 中更新方法的类型时,我发现我只能为唯一字段包含一个 where 子句:

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

我很乐意将其与身份验证结合起来并执行类似操作:

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

这在 Prisma 中完全可行吗?还是我需要一个单独的查询来检索实例?

最佳答案

在这种情况下,您需要使用 updateMany因为您将非唯一字段与唯一字段一起使用。

关于node.js - Prisma:使用具有非唯一字段的 "where"进行更新?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67556792/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com