织物超级复合键

问题描述 投票:0回答:1

我正在查看高吞吐量链代码示例,并对复合键有疑问。

在代码中,密钥创建如下

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

是否可以通过'op'或'value'来省略或使用一些通配符来表示'varName'?或者我是否需要为我想要查询的每个id创建不同的索引复合键,例如marbles_chaincode示例?另一个选择是使用couchDB for state database来支持更复杂的查询?

因为我要将一些JSON数据保存到分类帐中,我需要通过不同的密钥进行查询(在大理石示例中,让我们说颜色或大小)。

最好的问候和节日快乐!

hyperledger-fabric
1个回答
0
投票

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

// 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来检索您的

© www.soinside.com 2019 - 2024. All rights reserved.