Hyperledger Composer查询返回空白数组

时间:2019-02-04 00:16:45

标签: hyperledger-fabric hyperledger hyperledger-composer

我在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资源管理器中执行此查询时,都会出现一个空数组。有人遇到过这个问题吗?我似乎找不到修复程序,这真的让我感到困扰,因为我确实需要在我的应用程序上执行查询。

1 个答案:

答案 0 :(得分:0)

第一件事,文件名为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