我正在处理超级广告结构。我想访问' eventEmitted'超级结构织物的交易历史中的字段。
/*transaction history*/
"transactionType": "com.acn.hps.aops.ims.addingEvidence",
"eventsEmitted": [
{
"$class": "com.acn.hps.aops.ims.BasicEvent",
"evidenceId": "100",
"eventId":
"b66fd1c38754519339172905d916497376029ad9620ba5f19999fb73cf1d8b58#0",
"timestamp": "2018-03-01T08:36:41.164Z"
}
]
我能够查询事务类型并得到结果,但现在要访问eventEmitted中的证据id字段,如果我传递_ $ evidenceId并且它与eventEmitted中的字段evidenceId匹配
query showEvidenceAllHistorians {
description: "get all assetDoc transactions"
statement: SELECT org.hyperledger.composer.system.HistorianRecord
WHERE (transactionType == 'com.acn.hps.aops.ims.addingEvidence')
}
答案 0 :(得分:1)
我不知道CONTAINS不是你想要的答案吗?但是你可以尝试一下
答案 1 :(得分:0)
类似于:(这是基于trade-network
作为我们在Github上的示例网络中的示例:
return query('History') // eg. just a standard Historian query where emittedEvents are recorded
.then(function (results) {
for (var n = 0; n < results.length; n++) {
var element = results[n];
if (element.eventsEmitted[0] == 'Resource {id=org.acme.trading.TradeNotification#ee730e99-ba77-48b4-83a1-480e7218b7ff#0}') {
console.log('Historical record # ' + (n+1) + ', object is : ' + element);
console.log('eventEmitted: ' + element.eventsEmitted[0]);
var firsteventElement = element.eventsEmitted[0];
console.log('New var is ' + firsteventElement);
var fieldVal = element.eventsEmitted[0].commodity; // field defined in my Event in the model
console.log('New var is ' + firsteventElement + 'commodity id in the event Emitted is ' + fieldVal);
}
} /// for
});