model DataProvider {
id Int
name String
applications Application[]
@@map("data_providers")
}
model Application {
id Int
name String
data_provider_id Int
running Boolean
data_providers DataProvider
@@map("applications")
}
我想为每个 dataProvider 获取running = true
有多少个应用程序。
DataProvider Application
----------------- -----------------------------------------------
id | name id | name | data_provider_id | running
----------------- -----------------------------------------------
1 | dp1 2 | app2 | 1 | true
-----------------------------------------------
3 | app3 | 1 | false
相应地达到这个结果
dataProvider = {id: 1, name: 'dp1', _count: {applications: 1}}
我试过查询
this.prisma.dataProvider.findMany({
include: {
_count: {
select: {
applications: true
}
}
},
where: {
applications: {
some: {
running: {
equals: true
}
}
}
},
})
我想我总是得到{applications: 2}
2 to 的结果some
,但我只能使用some
,every
和none
。我错了什么?