Hyperledger Composer 查询返回空白数组

Hyperledger Composer query returning blank array

我在 query.qry 文件中定义了以下查询:

query selectItemsByOwner { description: "Select all items based on their owner uid" statement: SELECT org.example.auctchain.Item WHERE (owner.uid == _$uid) }

我的ACL权限文件有如下规则:

rule Auctioneer {
description: "Allow the auctioneer full access"
participant: "org.example.auctchain.Auctioneer"
operation: ALL
resource: "org.example.auctchain.*"
action: ALLOW
}

rule Member {
description: "Allow the member read access"
participant: "org.example.auctchain.Member"
operation: READ
resource: "org.example.auctchain.*"
action: ALLOW
}

rule VehicleOwner {
description: "Allow the owner of a vehicle total access"
participant(m): "org.example.auctchain.Member"
operation: ALL
resource(v): "org.example.auctchain.Item"
condition: (v.owner.getIdentifier() == m.getIdentifier())
action: ALLOW
}

rule VehicleListingOwner {
description: "Allow the owner of a vehicle total access to their 
vehicle listing"
participant(m): "org.example.auctchain.Member"
operation: ALL
resource(v): "org.example.auctchain.ItemListing"
condition: (v.vehicle.owner.getIdentifier() == m.getIdentifier())
action: ALLOW
}

rule SystemACL {
description:  "System ACL to permit all access"
participant: "org.hyperledger.composer.system.Participant"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}

rule NetworkAdminUser {
description: "Grant business network administrators full access to 
user resources"
participant: "org.hyperledger.composer.system.NetworkAdmin"
operation: ALL
resource: "**"
action: ALLOW
}

rule NetworkAdminSystem {
description: "Grant business network administrators full access to 
system resources"
participant: "org.hyperledger.composer.system.NetworkAdmin"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}

而我的 CTO 文件定义了涉及的资产和参与者如下:

asset Item identified by itemId {
o String itemId
o String name
o ItemType type
--> Member owner
}

abstract participant User identified by uid {
o String uid
o String email
o String firstName
o String lastName
o String phoneNumber
}

participant Member extends User {
o Double balance
}

我更新了 package.json 版本并创建了 BNA 文件,然后将其安装在我的网络上并进行了升级,一切顺利。当我从我的 Angular 应用程序或 Composer REST API Explorer 执行此查询时,问题就来了,两者都是 return 一个空数组。有人遇到过这个问题吗?我似乎找不到修复程序,这真的很困扰我,因为我真的需要在我的应用程序上执行查询。

首先,文件名是queries.qry

据我所知,Hyperledger Composer目前不支持它。

你可以在这里做一件事,修改你的查询如下:

query selectItemsByOwner {
  description: "Select all items based on their owner uid"
  statement:
      SELECT org.dd2.Item
          WHERE (owner == _$owner_res)
}

并且当您执行查询时,将完整的资源字符串作为输入,如下所示:

resource:org.dd2.Member#m1