docs: fix toc links (#13770)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Abstract
|
||||
# Group ORM
|
||||
|
||||
The orm package provides a framework for creating relational database tables with primary and secondary keys.
|
||||
|
||||
@@ -16,7 +16,7 @@ The orm package provides a framework for creating relational database tables wit
|
||||
* [Iterator](#iterator)
|
||||
* [Pagination](#pagination)
|
||||
|
||||
# Table
|
||||
## Table
|
||||
|
||||
A table can be built given a `codec.ProtoMarshaler` model type, a prefix to access the underlying prefix store used to store table data as well as a `Codec` for marshalling/unmarshalling.
|
||||
|
||||
@@ -37,7 +37,7 @@ The `table` struct is private, so that we only have custom tables built on top o
|
||||
|
||||
`table` provides methods for exporting (using a [`PrefixScan` `Iterator`](03_iterator_pagination.md#iterator)) and importing genesis data. For the import to be successful, objects have to be aware of their primary key by implementing the [`PrimaryKeyed`](#primarykeyed) interface.
|
||||
|
||||
## AutoUInt64Table
|
||||
### AutoUInt64Table
|
||||
|
||||
`AutoUInt64Table` is a table type with an auto incrementing `uint64` ID.
|
||||
|
||||
@@ -47,11 +47,11 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/group/internal/orm/auto_uint
|
||||
|
||||
It's based on the `Sequence` struct which is a persistent unique key generator based on a counter encoded using 8 byte big endian.
|
||||
|
||||
## PrimaryKeyTable
|
||||
### PrimaryKeyTable
|
||||
|
||||
`PrimaryKeyTable` provides simpler object style orm methods where are persisted and loaded with a reference to their unique primary key.
|
||||
|
||||
### PrimaryKeyed
|
||||
#### PrimaryKeyed
|
||||
|
||||
The model provided for creating a `PrimaryKeyTable` should implement the `PrimaryKeyed` interface:
|
||||
|
||||
@@ -62,7 +62,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/group/internal/orm/primary_k
|
||||
`PrimaryKeyFields()` method returns the list of key parts for a given object.
|
||||
The primary key parts can be []byte, string, and `uint64` types.
|
||||
|
||||
### Key codec
|
||||
#### Key codec
|
||||
|
||||
Key parts, except the last part, follow these rules:
|
||||
|
||||
@@ -70,7 +70,7 @@ Key parts, except the last part, follow these rules:
|
||||
* strings are null-terminated
|
||||
* `uint64` are encoded using 8 byte big endian.
|
||||
|
||||
# Secondary Index
|
||||
## Secondary Index
|
||||
|
||||
Secondary indexes can be used on `Indexable` [tables](01_table.md). Indeed, those tables implement the `Indexable` interface that provides a set of functions that can be called by indexes to register and interact with the tables, like callback functions that are called on entries creation, update or deletion to create, update or remove corresponding entries in the table secondary indexes.
|
||||
|
||||
@@ -78,7 +78,7 @@ Secondary indexes can be used on `Indexable` [tables](01_table.md). Indeed, thos
|
||||
https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/group/internal/orm/types.go#L88-L93
|
||||
```
|
||||
|
||||
## MultiKeyIndex
|
||||
### MultiKeyIndex
|
||||
|
||||
A `MultiKeyIndex` is an index where multiple entries can point to the same underlying object.
|
||||
|
||||
@@ -99,15 +99,15 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/group/internal/orm/indexer.g
|
||||
The currently used implementation of an `indexer`, `Indexer`, relies on an `IndexerFunc` that should be provided when instantiating the index. Based on the source object, this function returns one or multiple index keys as `[]interface{}`. Such secondary index keys should be bytes, string or `uint64` in order to be handled properly by the [key codec](01_table.md#key-codec) which defines specific encoding for those types.
|
||||
In the index prefix store, the keys are built based on the source object's `RowID` and its secondary index key(s) using the key codec and the values are set as empty bytes.
|
||||
|
||||
## UniqueIndex
|
||||
### UniqueIndex
|
||||
|
||||
As opposed to `MultiKeyIndex`, `UniqueIndex` is an index where duplicate keys are prohibited.
|
||||
|
||||
# Iterator and Pagination
|
||||
## Iterator and Pagination
|
||||
|
||||
Both [tables](01_table.md) and [secondary indexes](02_secondary_index.md) support iterating over a domain of keys, through `PrefixScan` or `ReversePrefixScan`, as well pagination.
|
||||
|
||||
## Iterator
|
||||
### Iterator
|
||||
|
||||
An `Iterator` allows iteration through a sequence of key value pairs.
|
||||
|
||||
@@ -129,7 +129,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/group/internal/orm/index.go#
|
||||
|
||||
Under the hood, both use a prefix store `Iterator` (alias for tm-db `Iterator`).
|
||||
|
||||
## Pagination
|
||||
### Pagination
|
||||
|
||||
The `Paginate` function does pagination given an [`Iterator`](#iterator) and a `query.PageRequest`, and returns a `query.PageResponse`.
|
||||
It unmarshals the results into the provided dest interface that should be a pointer to a slice of models.
|
||||
|
||||
Reference in New Issue
Block a user