fabric hyperledger composite key



我正在查看高通量链码示例,并有一个有关复合键的问题。

在代码中,键是如下创建的

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

是否可以通过' op '或' value '省略或使用某些通配符对' varname '使用某些通配符?还是我需要创建不同的索引复合键,例如我想查询的每个ID中的Marbles_ChainCode示例中?另一个选项是使用CouchDB用于支持更复杂查询的状态数据库?

由于我要将一些JSON数据保存到分类帐中,我需要通过不同的键查询(在大理石示例中,例如颜色或尺寸)。

最好的问候和节日快乐!

我建议您考虑使用CouchDB作为状态数据库,因为它为您提供了相当全面的查询功能,这是一种比顶级DB上的复合键更具表现力的方式。如果您以JSON格式存储文档,这可能特别有用。无论如何,请检查此couchdb查询语法以获取更多信息。

// 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)

您可以使用以下API检索

最新更新