0

I am developing a simple Hyperledger Fabric Wallet type application in Java chaincode with basically 2 models: Wallet and MoneyTransfer. MoneyTransfer has the data, amount and ids for "fromWallet" and "targetWallet".

I have not found examples of how to do a query in the ChaincodeStub to fetch, for example, all MoneyTransfer's for a specific walletId. Is this possible or models can only be fetched by id?

Any URL for doc or help on how to do this? (Samples I have found just fetch models by Id but don't perform queries based on specific properties in the models) Thanks.

icordoba
  • 1,834
  • 2
  • 33
  • 60

1 Answers1

0

Using CouchDB as the state database you should be able to write JSON objects into the state database and run "rich" queries against a particular property in the JSON object. There are samples for doing this in Javascript and in Go, but I don't know if there are any for Java.

These docs give the background:

https://hyperledger-fabric.readthedocs.io/en/latest/couchdb_tutorial.html

https://hyperledger-fabric.readthedocs.io/en/latest/couchdb_as_state_database.html

R Thatcher
  • 5,550
  • 1
  • 7
  • 15