通过查询检索关系的属性

时间:2018-05-18 14:34:52

标签: hyperledger-fabric hyperledger hyperledger-composer ibm-blockchain

我想创建一个查询,返回所有请求(资产),其中Container(资产)所有者的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)
}

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

2 个答案:

答案 0 :(得分:2)

我还使用查询文件进行了大量研究,但是找不到方法,所以我认为现在不可能。

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

类似的东西:

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

答案 1 :(得分:0)

您可以像按数字搜索一样上一层楼。如果得到确切的解决方案,我正在努力。

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