通过查询检索关系的属性



我想创建一个查询,该查询返回容器(资产)所有者的ID等于参数的所有请求(资产)。

模型文件(容器的所有者是公司参与者,由 id 标识):

namespace org.acme.shipping.assets
import org.acme.shipping.participants.*
asset Container identified by number {
o String number
o ContainerType type
o String content
o ContainerStatus status default = "FREE"
--> Company owner
}
enum ContainerType {
o DRY
o REEFER
}
enum ContainerStatus {
o LOCKED
o FREE
}
asset Request identified by id {
o String id
--> Container container
}

查询文件

query getRequestsByCompany {
description: "Get requests by company"
statement:
SELECT org.acme.shipping.assets.Request
WHERE (container.owner.id == _$company_id)
}

但是,当前查询似乎不起作用。这可以通过查询实现吗?

我也做了很多研究来使用查询文件来做到这一点,但找不到方法,所以我认为目前不可能。

另一种方法是使用环回过滤器:

  • https://github.com/hyperledger/composer-knowledge-wiki/blob/latest/knowledge.md#information_source--filters-loopback
  • https://loopback.io/doc/en/lb2/Where-filter.html

像这样:

{"where":{"shipmentId":1000}, "include":"resolve"}

您可以按数字搜索一个级别。如果得到确切的解决方案,我正在努力.

query getRequestsByCompany {
description: "Get requests by company"
statement:
SELECT org.acme.shipping.assets.Request
WHERE (container == _$container)
}

最新更新