how to access the 'eventEmitted' field in transaction history of hyperledger fabric

前端 未结 2 1093
失恋的感觉
失恋的感觉 2021-01-29 00:23

I am working on hyperledger fabric.I want to access the \'eventEmitted\' field in transaction history of hyperledger fabric.

 /*transaction history*/
  \"transac         


        
相关标签:
2条回答
  • 2021-01-29 00:46

    something like: (this is based on the trade-network as a sample from our sample-networks on 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
    
               });  
    
    0 讨论(0)
  • 2021-01-29 01:03

    I do not know CONTAINS is not the answer you want? But you can give it a try

    0 讨论(0)
提交回复
热议问题