hyperledger-fabric - 通过查询检索关系的属性
问题描述
我想创建一个查询,它返回容器(资产)所有者的 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"}
推荐阅读
- android - WorkManager 使用 Livedata 观察状态
- html - 背景图像在 vuejs 中没有完全扩展
- ruby-on-rails - mongoid 7.1 / mongo 4.0 急切加载不起作用
- openstack - 在 swift 对象存储中将完整磁盘设为只读
- sql - 将 varchar 转换为浮点数的 SQL (Server) 错误。文字+金额
- c# - 不能逐渐降低音量
- javascript - 在 fabric.js 如何获取活动对象上的项目(计数)
- javascript - setState 在 handleSubmit 中被忽略
- amazon-web-services - AWS Application Load Balancer - Lambda 响应仅包含正文
- visual-studio-code - 如何使用 Linux 风格的 gcc 错误设置 VSCode 的问题匹配器