ddb

package
v0.0.0-...-461d331 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec[T dynamo.Thing] struct {
	// contains filtered or unexported fields
}

Codec is utility to encode/decode objects to dynamo representation

func NewCodec

func NewCodec[T dynamo.Thing](uri *dynamo.URL) *Codec[T]

func (Codec[T]) Decode

func (codec Codec[T]) Decode(gen map[string]types.AttributeValue) (T, error)

Decode dynamo representation to object

func (Codec[T]) Encode

func (codec Codec[T]) Encode(entity T) (map[string]types.AttributeValue, error)

Encode object to dynamo representation

func (Codec[T]) EncodeKey

func (codec Codec[T]) EncodeKey(key T) (map[string]types.AttributeValue, error)

EncodeKey to dynamo representation

func (Codec[T]) KeyOnly

func (codec Codec[T]) KeyOnly(gen map[string]types.AttributeValue) map[string]types.AttributeValue

KeyOnly extracts key value from generic representation

type Schema

type Schema[T dynamo.Thing] struct {
	ExpectedAttributeNames map[string]string
	Projection             *string
}

Schema is utility that decodes type into projection expression

func NewSchema

func NewSchema[T dynamo.Thing]() *Schema[T]

type Storage

type Storage[T dynamo.Thing] struct {
	Service dynamo.DynamoDB
	Table   *string
	Index   *string
	Codec   *Codec[T]
	Schema  *Schema[T]
	// contains filtered or unexported fields
}

ddb internal handler for dynamo I/O

func (*Storage[T]) Get

func (db *Storage[T]) Get(ctx context.Context, key T) (T, error)

Get item from storage

func (*Storage[T]) Match

func (db *Storage[T]) Match(ctx context.Context, key T) dynamo.Seq[T]

Match applies a pattern matching to elements in the table

func (*Storage[T]) Put

func (db *Storage[T]) Put(ctx context.Context, entity T, config ...dynamo.Constraint[T]) error

Put writes entity

func (*Storage[T]) Remove

func (db *Storage[T]) Remove(ctx context.Context, key T, config ...dynamo.Constraint[T]) error

Remove discards the entity from the table

func (*Storage[T]) Update

func (db *Storage[T]) Update(ctx context.Context, entity T, config ...dynamo.Constraint[T]) (T, error)

Update applies a partial patch to entity and returns new values

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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