我在查询数据,其中的结构是这样的。
我有两个模特,FoodDrinks和。他们之间有许多关系。
现在开始下面的查询
{
"filter": {
"include": "cuisines"
}
}我得到了以下结果。
[
{
"id": 1,
"name": "Biryani",
"cuisines": [
{
"id": 1,
"name": "Mughlai"
},
{
"id": 2,
"name": "North Indian"
},
{
"id": 3,
"name": "Afghani"
}
]
},
{
"id": 2,
"name": "Chhole Bhature",
"cuisines": [
{
"id": 2,
"name": "North Indian"
}
]
},
{
"id": 3,
"name": "Amritsari Naan",
"cuisines": [
{
"id": 2,
"name": "North Indian"
},
{
"id": 6,
"name": "Punjabi"
},
]
}
]现在,我只想要那些食品饮料,其中有以下一系列的菜系。
let cuisinesIDs = ["1", "2"]下面的查询是什么?
发布于 2018-10-01 21:15:06
我想像下面这样的东西应该能起作用:
{
"filter": {
"include": "cuisines"
},
"where": {
"cuisines.id": {
"inq": cuisinesIDs
}
}
}发布于 2018-10-03 14:02:52
这可能与@Behrooz的答案相同,但我会尝试:
{
"filter": {
"include": {
relation: 'cuisines',
scope: {
where: {
id: {inq: cuisinesIDs}
}
}
}
}
}https://stackoverflow.com/questions/52597699
复制相似问题