是否可以对孩子进行条件查询?我正在尝试返回所有组,以及所有计数大于 0 的子组(以及子组)。请注意,如果计数大于 0,子组也需要返回子组。
文档:
{
"id": 1,
"name": "name1",
"groups": [
{
"id": 1,
"name": "name1",
"subGroups": [
{
"id": 1,
"name": "name1",
"count": 4,
"assests": [ "asset1", "asset2" ]
},
{
"id": 2,
"name": "name2",
"count": 0,
"assests": [ "asset1", "asset2" ]
}
]
},
{
"id": 2,
"name": "name2",
"subGroups": [
{
"id": 1,
"name": "name1",
"count": 4,
"assests": [ "asset1", "asset2" ]
},
{
"id": 2,
"name": "name2",
"count": 0,
"assests": [ "asset1", "asset2" ]
}
]
}
]
}
想要的结果:
{
"id": 1,
"name": "name1",
"groups": [
{
"id": 1,
"name": "name1",
"subGroups": [
{
"id": 1,
"name": "name1",
"count": 4,
"assests": [ "asset1", "asset2" ]
}
]
},
{
"id": 2,
"name": "name2",
"subGroups": [
{
"id": 1,
"name": "name1",
"count": 2,
"assests": [ "asset1", "asset2" ]
}
]
}
]
}
我尝试通过加入来做,但还没有找到一种可以跳过一些子组而不是其他子组的方法。欢迎所有建议。