foundations

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func EnableErrorWithEmptyList added in v0.1.7

func EnableErrorWithEmptyList(v bool)

EnableErrorWithEmptyList Make the list return an error if it is empty.

func Get

func Get(ctx context.Context, cli GetClient, getKeys GetKeyFunc, fetch FetchItemFunc, opt ...options.Option) (*dynamodb.GetItemOutput, error)

func IsNil

func IsNil(record interface{}) bool

func IsNotFound

func IsNotFound(err error) bool

func NotFound added in v0.1.4

func NotFound(tableName string) *types.ResourceNotFoundException

func Put

func Query added in v0.0.2

func Scan added in v0.0.6

func Scan(ctx context.Context, cli ScanClient, condition ScanFilterFunc, fetch FetchItemsFunc, opt ...options.Option) (*dynamodb.ScanOutput, error)

func UpdateBuilder added in v0.1.3

func UpdateBuilder(ctx context.Context, fields ...UpdateField) expression.UpdateBuilder

Types

type Client added in v0.1.3

type Client interface {
	GetClient
	ScanClient
	QueryClient
	WriteClient
}

type ExpressionFunc added in v0.1.6

type ExpressionFunc func() (expr expression.Expression, err error)

type FetchItemFunc

type FetchItemFunc func(tableName string, value map[string]types.AttributeValue) error

func FetchItem added in v0.1.3

func FetchItem[T any](rec *T) FetchItemFunc

type FetchItemsFunc added in v0.0.2

type FetchItemsFunc func(tableName string, value []map[string]types.AttributeValue) error

func FetchItems added in v0.1.3

func FetchItems[T any](rec *T) FetchItemsFunc

type GetClient

type GetClient interface {
	GetItem(ctx context.Context, params *dynamodb.GetItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
}

type GetItemFunc added in v0.0.9

type GetItemFunc WriteItemFunc

type GetKeyFunc

type GetKeyFunc func() (table string, keys map[string]types.AttributeValue, attrs []string, err error)

type PutItemPreprocessor added in v0.1.3

type PutItemPreprocessor interface {
	BeforePutItem(ctx context.Context) any
}

type QueryClient added in v0.0.2

type QueryClient interface {
	Query(ctx context.Context, params *dynamodb.QueryInput, optFns ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)
}

type QueryConditionFunc added in v0.0.2

type QueryConditionFunc func() (table, index string, expr expression.Expression, err error)

type ScanClient added in v0.0.6

type ScanClient interface {
	Scan(ctx context.Context, params *dynamodb.ScanInput, optFns ...func(*dynamodb.Options)) (*dynamodb.ScanOutput, error)
}

type ScanFilterFunc added in v0.1.3

type ScanFilterFunc func() (table string, expr expression.Expression, err error)

type UpdateField

type UpdateField func(ctx context.Context, builder *expression.UpdateBuilder) expression.UpdateBuilder

func UpdateValue added in v0.1.3

func UpdateValue(name string, value any) UpdateField

type WriteClient

type WriteClient interface {
	PutItem(ctx context.Context, params *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
	UpdateItem(ctx context.Context, params *dynamodb.UpdateItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.UpdateItemOutput, error)
	DeleteItem(ctx context.Context, params *dynamodb.DeleteItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DeleteItemOutput, error)
}

type WriteItemFunc

type WriteItemFunc func() (table string, item map[string]types.AttributeValue, expr expression.Expression, err error)

func ConsistentUpdateItem added in v0.1.3

func ConsistentUpdateItem(ctx context.Context, keyFunc GetKeyFunc, fieldName string, count int, fields ...UpdateField) WriteItemFunc

func DeleteItem added in v0.1.3

func DeleteItem(keyFunc GetKeyFunc) WriteItemFunc

func PutItem added in v0.1.3

func PutItem(ctx context.Context, tableName string, rec any, f ...ExpressionFunc) WriteItemFunc

func UpdateItem added in v0.1.3

func UpdateItem(ctx context.Context, keyFunc GetKeyFunc, fields ...UpdateField) WriteItemFunc

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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