首页 > 解决方案 > 通过查询检索关系的属性

问题描述

我想创建一个查询,它返回容器(资产)所有者的 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)
}

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

标签: hyperledger-fabrichyperledgerhyperledger-composeribm-blockchain

解决方案


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

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

就像是:

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

推荐阅读