简体   繁体   中英

How to fetch Models with a property query based in Hyperledger Fabric Java chaincode

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM