Hyperledger Fabric中的查询在使用NodeJ的多个参数时发生错误

时间:2019-11-24 15:10:10

标签: node.js hyperledger-fabric blockchain hyperledger-composer

我有一个如下所示的javascript(NodeJS)代码。我不知道为什么会出现错误。我知道错误在查询中。您能告诉我用多种参数查询的正确方法吗?我有更多细节的控制台。希望您的答复。 谢谢。[![在此处输入图片描述] [1]] [1]

    console.log("start get Request");

    let businessNetworkConnection = new BusinessNetworkConnection();

    try {
        // await businessNetworkConnection.connect('3@identity');
        await businessNetworkConnection.connect('admin@tutorial-network');

        var idRequester="resource:org.basic.server.Patient#"+identityCardNumber;
        var idResourceOwner="resource:org.basic.server.Patient#"+identityCardNumber;
        console.log("begin query patient");
        let results=await businessNetworkConnection.query('selectRequestHaveIdentityCardNumber',{"owner":idRequester,"resourceOwner":idResourceOwner});
        console.log("end query patient");

        //disconect admin card
        await businessNetworkConnection.disconnect();
        // console.log(result);

        console.log("request result: "+results);
        return results;
    } catch (error) {
        await businessNetworkConnection.disconnect();
        var results = {
            requestId: 'requestId',
            requesterRole: 'requesterRole',
            resourceOwnerRole: 'resourceOwnerRole',
            resourceType: 'resourceType',
            resourceId: 'resourceId',
            idRequester: 'idRequester',
            idResourceOwner: 'idResourceOwner'
        };
        //error: trung id card
        //console.error(error);
        console.log("this is error");
        return results;
        // process.exit(1);
    }
    //return 1;
}```

And this query:
```query selectRequestHaveIdentityCardNumber {
  description: "Select Request have Identity Card Number"
  statement: 
    SELECT org.basic.server.Request
    WHERE (owner == _$idRequester  OR resourceOwner ==_$idResourceOwner )
}```

And this Asset:
```asset Request identified by requestId {
  o String requestId
  o Role requesterRole
  o Role resourceOwnerRole
  o ResourceType resourceType
  o RequestStatus status
  o String resourceId

  --> Person owner
  --> Person resourceOwner
}```


  [1]: https://i.stack.imgur.com/n9OYn.png

0 个答案:

没有答案