Prisma查询Upsert
我该如何在Prisma中进行此查询:
INSERT INTO user_conference (user_id, conference_id, points, activities_completed)
VALUES (1, '3a4QQI0KbO0eaDjzhIgeeZ', 40, ARRAY ['4vwp3L1EJYQ9rI1Pv7er2'])
ON CONFLICT (user_id, conference_id) DO UPDATE
SET points = user_conference.points + 40,
activities_completed = user_conference.activities_completed || '4vwp3L1EJYQ9rI1Pv7c4x0'::text
How can I do this query in prisma:
INSERT INTO user_conference (user_id, conference_id, points, activities_completed)
VALUES (1, '3a4QQI0KbO0eaDjzhIgeeZ', 40, ARRAY ['4vwp3L1EJYQ9rI1Pv7er2'])
ON CONFLICT (user_id, conference_id) DO UPDATE
SET points = user_conference.points + 40,
activities_completed = user_conference.activities_completed || '4vwp3L1EJYQ9rI1Pv7c4x0'::text
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个较晚的答案,但可以帮助他人。
我的看法是,在Postgres 冲突上期望唯一字段或具有独特约束的字段组合。 Prisma也是如此。
Prisma模型上,请使用此。
在您直接查询翻译的
This is a late answer, but it could help others.
The way I see it, on Postgres ON CONFLICT expect a unique field or a combination of fields with unique constraints. This goes the same for PRISMA.
On your Prisma model
For your direct query translation, use this.