Documentation ¶
Index ¶
- Variables
- type SeqCollection
- func (c SeqCollection[V]) Append(ctx context.Context, obj *V) (uint64, error)
- func (c SeqCollection[V]) Export(ctx context.Context) ([]V, error)
- func (c SeqCollection[V]) Get(ctx context.Context, id uint64) (V, error)
- func (c SeqCollection[V]) Import(ctx context.Context, values []V, getIDFn func(V) uint64) error
- func (c SeqCollection[V]) Set(ctx context.Context, id uint64, obj V) error
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrInvalidID = fmt.Errorf("invalid ID")
)
Functions ¶
This section is empty.
Types ¶
type SeqCollection ¶
type SeqCollection[V any] struct { collections.Map[uint64, V] // contains filtered or unexported fields }
SeqCollection is an opinionated collection built on top of Cosmos SDK's Collections that uses a Sequence as ID for the Map.
The sequence will start from 1 to avoid using 0 as an ID which prevents unexpected behaviours, for example when marshalling data as JSON default values are omitted by default.
func NewSeqCollection ¶
func NewSeqCollection[V any]( seq collections.Sequence, m collections.Map[uint64, V], setId func(*V, uint64), ) SeqCollection[V]
func (SeqCollection[V]) Append ¶
func (c SeqCollection[V]) Append(ctx context.Context, obj *V) (uint64, error)
func (SeqCollection[V]) Export ¶ added in v0.1.1
func (c SeqCollection[V]) Export(ctx context.Context) ([]V, error)
func (SeqCollection[V]) Get ¶
func (c SeqCollection[V]) Get(ctx context.Context, id uint64) (V, error)
Click to show internal directories.
Click to hide internal directories.