store

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Spanner

type Spanner[T Storable] struct {
	// contains filtered or unexported fields
}

Spanner store for elements.

func InSpanner

func InSpanner[T Storable](client *spanner.Client) *Spanner[T]

InSpanner stores items backed by a Spanner database.

func (*Spanner[T]) Get

func (s *Spanner[T]) Get(ctx context.Context, key spanner.Key) (T, error)

Get an element from the store by key.

func (*Spanner[T]) Insert

func (s *Spanner[T]) Insert(ctx context.Context, item T) error

Insert an item into the store.

func (*Spanner[T]) List

func (s *Spanner[T]) List(ctx context.Context, prefix spanner.Key, limit, offset int64) ([]T, error)

List elements with limit and offset for pagination.

type Storable

type Storable interface {
	Key() spanner.Key
	Table() string
	List(prefix spanner.Key, limit, offset int64) spanner.Statement
}

Storable in a database.

type Store

type Store[T Storable] interface {
	Insert(context.Context, T) error
	Get(context.Context, spanner.Key) (T, error)
	List(context.Context, spanner.Key, int64, int64) ([]T, error)
}

Store elements of type T in a database.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL