如何在Prisma中过滤关联数据?查询报错t4.id不存在
Prisma查询报错:t4.id列不存在问题解决
→ 60 const schools = await this.prisma.school.findMany(
The columnt4.iddoes not exist in the current database.
我在使用Prisma查询数据时遇到上述错误,只有移除代码中214-216行(select.semesters.where内的subjects过滤逻辑)错误才会消失,但我需要过滤semesters,不能删除这些行。
我的查询代码如下:
const schools = await this.prisma.school.findMany({ where: { semesters: { some: { isActive: true, subjects: { none: {}, }, }, }, }, select: { id: true, name: true, semesters: { where: { isActive: true, subjects: { // line:214 none: {} // line:215 } // line:216 }, select: { id: true, subjects: { select: { id: true } } }, }, }, take: 100, });
我知道可以通过客户端二次处理实现需求,但更希望直接在查询阶段完成:
const schools = ... const filteredSchools = schools.map(...).filter(...);
内容的提问来源于stack exchange,提问作者schutte
相关产品推荐
相关产品推荐

