dari

package module
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DynamodbMaxTxItems = 25

Variables

View Source
var ErrAlreadyExists = errors.New("already exists")
View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrNotSupportNoSk = errors.New("not supported, no sk on table")

Functions

func Delete

func Delete[T any](ctx context.Context, t *Table, k Keys) error

func Get

func Get[T any](ctx context.Context, t *Table, k Keys) (*T, error)

func GetPut added in v0.2.5

func GetPut[T Keys](ctx context.Context, t *Table, item *T, mutator func(*T) error, maxRetries int) error

GetPut reads an item, applies mutator to the freshly-read copy, and writes it back. If the put fails because of a version constraint (another writer updated the item between the Get and Put), GetPut re-reads the item and retries, up to maxRetries attempts.

Warning: mutator may be called multiple times — once per attempt — so it must be safe to re-run against a freshly-read copy each time. If mutator returns a non-nil error, GetPut aborts immediately without retrying.

func ListWithPrefix

func ListWithPrefix[T any](ctx context.Context, t Queryable, k Keys) ([]T, error)

func Put

func Put[T Keys](ctx context.Context, t *Table, item *T) error

func PutTx added in v0.2.5

func PutTx(ctx context.Context, t *Table, items ...Keys) error

Types

type Key

type Key interface {
	Key() (string, string)
}

type KeyName

type KeyName string
var TableKey KeyName

type KeySet

type KeySet map[KeyName]KeyValues

type KeyValues

type KeyValues [2]string

type Keys

type Keys interface {
	Keys() KeySet
}

type Queryable

type Queryable interface {
	TableName() string
	Pk() string
	Sk() string
	IndexName() KeyName

	Client() *dynamodb.Client
	// contains filtered or unexported methods
}

type Table

type Table struct {
	// contains filtered or unexported fields
}

func NewTable

func NewTable(client *dynamodb.Client, name, pk, sk, version string) *Table

func (*Table) Client

func (t *Table) Client() *dynamodb.Client

func (*Table) IndexName

func (t *Table) IndexName() KeyName

func (*Table) Pk

func (t *Table) Pk() string

func (*Table) PrefixPkValues

func (t *Table) PrefixPkValues(prefix string)

func (*Table) Sk

func (t *Table) Sk() string

func (*Table) TableName

func (t *Table) TableName() string

func (*Table) WithIndex

func (t *Table) WithIndex(indexName KeyName, pk, sk string) Queryable

func (*Table) WithSimilarTable added in v0.2.4

func (t *Table) WithSimilarTable(tableName string) *Table

type Version

type Version interface {
	VersionValue() int
}

Jump to

Keyboard shortcuts

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