简体   繁体   中英

fabric hyperledger composite key

i'm looking at the high-throughput chaincode example and have a question regarding the composite keys.

In the code the key is created as follows

compositeIndexName := "varName~op~value~txID"

Is it possible to query by ' op ' or ' value ' omitting or using some wildcard for the ' varName '? Or would I need to create different index composite keys, like in the marbles_chaincode example, for each id I would want to query? The other option is using the couchDB for state database which supports more complex querying?

As I'm gonna be saving some JSON data onto the ledger, which I'll need to query by different keys (in the marbles example let's say Color or Size).

Best regards and happy holidays!

I would recommend consider using CouchDB as state database since it provides you with quite comprehensive querying capabilities which a way more expressive than you can achieve with composite keys on top of level db. This could be especially useful in case you are storing your documents in JSON format. Anyway, check this CouchDB query syntax for more information.

// GetQueryResult performs a "rich" query against a state database. It is
// only supported for state databases that support rich query,
// e.g.CouchDB. The query string is in the native syntax
// of the underlying state database. An iterator is returned
// which can be used to iterate (next) over the query result set.
// The query is NOT re-executed during validation phase, phantom reads are
// not detected. That is, other committed transactions may have added,
// updated, or removed keys that impact the result set, and this would not
// be detected at validation/commit time.  Applications susceptible to this
// should therefore not use GetQueryResult as part of transactions that update
// ledger, and should limit use to read-only chaincode operations.
GetQueryResult(query string) (StateQueryIteratorInterface, error)

erefore you can use following API to retrieve your

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