I'm working on the latest rev of hyperledger-composer (V0.13) and have built a network with multiple roles, each of which can invoke selected transactions within the blockchain. I would now like to query the blockchain (?Historian?) for all transactions which have been executed against a specific Order (defined type of asset).
I've used two different appoaches to pulling Historian data, once through direct API access historian.getall()
and the other through a defined query:
query getHistorianRecords {
description: "get all Historian records"
statement: SELECT org.hyperledger.composer.system.HistorianRecord
}
Both queries succeed in that they return all transactions within the system. per ex:
ValidatedResource {
'$modelManager': ModelManager { modelFiles: [Object] },
'$namespace': 'org.hyperledger.composer.system',
'$type': 'HistorianRecord',
'$identifier': '0c3274475fed3703692bb7344453ab0910686905451b41d5d08ff1b032732aa1',
'$validator': ResourceValidator { options: {} },
transactionId: '0c3274475fed3703692bb7344453ab0910686905451b41d5d08ff1b032732aa1',
transactionType: 'org.acme.Z2BTestNetwork.CreateOrder',
transactionInvoked:
Relationship {
'$modelManager': [Object],
'$namespace': 'org.acme.Z2BTestNetwork',
'$type': 'CreateOrder',
'$identifier': '0c3274475fed3703692bb7344453ab0910686905451b41d5d08ff1b032732aa1',
'$class': 'Relationship' },
eventsEmitted: [],
transactionTimestamp: 2017-09-22T19:32:48.182Z }
What I can't find, and need, is a way to query the history of transactions against a single Order. An Order is defined (partial listing) as follows:
asset Order identified by orderNumber {
o String orderNumber
o String[] items
o String status
...
o String approved
o String paid
--> Provider provider
--> Shipper shipper
--> Buyer buyer
--> Seller seller
--> FinanceCo financeCo
What I'm looking for is a mechanism that will allow me to query the blockchain to get every record pertaining to an Order with orderNumber = '009'
. I can, and have, easily found the current state of Order # 009, but am now looking for the history of transactions against that order. How to I tell Historian, or another service in the hyperledger-composer system, to give me that information?