Documentation ¶
Overview ¶
Package index allows for creating indices in the state database.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPrettyLedgerKey ¶
GetPrettyLedgerKey is used for debugging print statements. Should only be used during debugging. Replaces global.MIN_UNICODE_RUNE_VALUE with "_" and global.MAX_UNICODE_RUNE_VALUE with "*". Composite keys are also prefixed with a global.MIN_UNICODE_RUNE_VALUE.
Example ¶
stub := cached_stub.NewCachedStub(test_utils.CreateExampleMockStub()) indexTable := GetTable(stub, "CustomAssetIndex", "objectId") ledgerKey, _ := indexTable.CreateRangeKey([]string{"color", "objectId"}, []string{"blue"}) GetPrettyLedgerKey(ledgerKey)
Output:
func GetTable ¶
func GetTable(stub cached_stub.CachedStubInterface, name string, options ...interface{}) table_interface.Table
GetTable returns the table from the ledger or creates a new one. Name is the name of the index table. Note: If table already exists, all options are ignored. This is because caller won't be able to change the options once the table is already created. options[0] is the name of the index field that will be used to uniquely identify a row in the table. If it is not provided, the table's primaryKeyId is set to "id". options[1] indicates whether to use custom binary tree implementation (on-chain) for index. Default value is false. options[2] indicates whether to encrypt index or not. Default value is false. options[3] datastoreConnectionID. if specified it will store index data to off-chain datastore. Note that currently only Cloudant off-chain datastore is supported for indexing. Also, when option[3] is specified, option[1] will be ignored.
Example ¶
stub := cached_stub.NewCachedStub(test_utils.CreateExampleMockStub()) GetTable(stub, "CustomAssetIndex", "objectId")
Output:
func Init ¶
func Init(stub cached_stub.CachedStubInterface, logLevel ...shim.LoggingLevel) ([]byte, error)
Init sets up the index package.
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
Package table_interface provides an interface for index table related methods.
|
Package table_interface provides an interface for index table related methods. |