Prisma,NextJs,嵌套查询问题,嵌套 where Provided Json,预期 Int

问题描述 投票:0回答:0

这是我人生中的第一篇文章。我喜欢编程,你是我的灵感……所以,让我们开始吧:

我的架构很大,所以我会尝试解释: · 1 个指南包含多个组件 · 1个组件有多个标签 · 1个标签有很多方面 · 1个方面有很多项

还有: · 1 guide_approvement 有 fk aspect_id, fk item_id, fk guide_id, fk department_id · 方面和项目必须获得评级

事情是这样的:我的查询做得很好,但我不能添加很多过滤器,我需要选择评级 active = true AND department_id = userDepartmentId 和其他人,但我只能很好地处理 where id: guide?。开头的id

阅读我尝试嵌套的文档 where with: where: { table: { is: { field: value ... 但我收到这个错误“Provided Json, expected Int.”

在下面几行中你会看到错误,这是有目的的,这是我想要接近的:

let data = {
table: "guide",
action: "get", // findUnique
body: {
where: { // not work
id: {
is: {
id: valueGuide?.id,
},
},
},
select: {
id: true,
date: true,
version: true,
component_guide: {
select: {
component: true,
},
orderBy: {
id: "asc",
},
},
tag_guide: {
select: {
tag: true,
},
orderBy: {
id: "asc",
},
},
aspect_guide: {
select: {
aspect: true,
},
orderBy: {
id: "asc",
},
},
item_guide: {
select: {
item: true,
},
orderBy: {
id: "asc",
},
},
guide_approvement: {
select: {
comment: true,
aspect_guide_id: true,
item_guide_id: true,
rating: {
select: {
value: true,
where: { // not work
is: {
active: true,
},
},
},
},
},
where: { // not work
departament_id: user.departament.id,
},
},
},
},
};

prisma.table.findUnique(网址,数据)

希望得到您的帮助,非常感谢

我尝试用 prisma 和 nextjs 做嵌套的地方,我希望得到帮助!谢谢。

json next.js nested where-clause prisma
© www.soinside.com 2019 - 2024. All rights reserved.