基于相关模型属性的环回滤波器 [英] Loopback Filter Based On Related Model Properties
问题描述
我希望能够根据相关模型的属性进行过滤.例如,我有一个带有建筑对象的Class对象.我想获取在特定建筑物中发生的课程的列表.
I want to be able to filter based on the properties of related models. For example, I have a Class object with a Building object. I want to get a list of classes that take place in a certain building.
此过滤器
{
"include":"building",
"scope":{
"where":{
"name":"warehouse"
}
}
}
返回所有类,但仅包含名称为仓库"的建筑物.我想要的是将建筑物名称上的where子句应用于整个过滤器,以便仅在建筑物具有该名称的情况下才获得该类.
returns all classes, but only includes building if its name is "warehouse". What I want is for the where clause on building name to apply to the whole filter so that I only get the class if it's building has that name.
有什么办法可以做我想做的事吗?
Is there any way to do what I want?
谢谢!
推荐答案
You can do this in code, see include with filters in the docs.
我不确定JSON,但我认为它应该更像这样:
I'm not sure about the JSON but I think it should look more like this:
include: {
relation: 'building',
scope: {
where: {name: 'warehouse'}
}
}
这篇关于基于相关模型属性的环回滤波器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!