在Loopback 3上,我可以使用api进行嵌套查询,如以下所示:
http://localhost/api/ServiceOrders?filter={
"where": { "id" : 4 } ,
"include": [
{ "itemModel" : "itemBrand" },
"itemSize" ]
} 对于Loopback4我正在尝试..。
http://localhost/ServiceOrders?filter={
"where": { "id": 4 },
"include": [
{
"relation": "itemModel",
"scope": {
"include": [ { "relation": "itemBrand"} ]
}
}
]
}但是不支持返回“范围”。
ps:基于Loopback4 post的Loopback 4 include nested relations新税。
谢谢,问候
发布于 2020-03-06 17:44:59
更新到@loopback/cli版本2.0.1 (我不知道这是否有帮助)
工作api:
http://localhost:3000/service-order?filter={
"where": { "modifiedOn": { "gt": "2020-01-01" } },
"include": [{
"relation": "itemModel",
"scope": { "include":[{"relation":"itemBrand"}] }
},
{ "relation": "itemSize" }
] }还检查每个关系是否包含存储库中的下列行:
this.itemBrand= this.createBelongsToAccessorFor('itemBrand', itemBrandRepositoryGetter,);
this.registerInclusionResolver('itemBrand', this.itemBrand.inclusionResolver);https://stackoverflow.com/questions/60081092
复制相似问题