简体   繁体   English

Prisma - 如何从间接关系中检索数据?

[英]Prisma - How to retrieve data from indirect relation?

I've started to work with Prisma and have built this given schema for a boot camp project, which is working fine.我已经开始使用 Prisma 并为新兵训练营项目构建了这个给定的模式,它运行良好。

I've been able to work with relations and nested fields for straightforward Prima's CRUD operations.我已经能够使用关系和嵌套字段来进行简单的 Prima 的 CRUD 操作。

But now I'm trying to, in a single call (of prisma.term.findMany ), get data in this model:但现在我试图在一次调用( prisma.term.findMany )中获取此模型中的数据:

data = {
    terms: [{id, name, 
        disciplines: [{id, name, 
            categories: [{id, name, 
                tests: [{id, name, pdfUrl, teacher}]
            }]
        }]
    }]
}

Right now, I can kind of do that following those relations: terms > disciplines > disciplines teachers > tests > categories.现在,我可以按照以下关系做到这一点:术语 > 学科 > 学科教师 > 测试 > 类别。 Then, I'm using another function just to remodel this object and return to the desired model.然后,我使用另一个函数来改造这个对象并返回到所需的模型。

The challenge is that there is no direct relation between disciplines and categories in the schema.挑战在于模式中的学科和类别之间没有直接关系。

Is it possible to return this data with 1 access, using select/include?是否可以使用选择/包含以 1 次访问权限返回此数据?

如果没有学科和类别之间的关系,不使用$queryRaw就不可能在一个查询中检索所有内容。

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

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