dynamox

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package dynamox contains DynamoDB utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttrAs

func AttrAs[T types.AttributeValue](
	item map[string]types.AttributeValue,
	name string,
) (v T, err error)

AttrAs fetches an attribute of type T from an item.

It returns an error if the item is absent or a different type.

func DeleteTableIfNotExists

func DeleteTableIfNotExists(
	ctx context.Context,
	client *dynamodb.Client,
	table string,
) error

DeleteTableIfNotExists deletes a DynamoDB table if it does not exist.

func NewTestClient

func NewTestClient(t testing.TB) *dynamodb.Client

NewTestClient returns a new DynamoDB client for use in a test.

func Range added in v0.9.1

func Range(
	ctx context.Context,
	client *dynamodb.Client,
	m func(any) []func(*dynamodb.Options),
	in *dynamodb.QueryInput,
	fn RangeFunc,
) error

Range executes a query and calls fn for each item in the result set.

func TryAttrAs added in v0.9.0

func TryAttrAs[T types.AttributeValue](
	item map[string]types.AttributeValue,
	name string,
) (v T, ok bool, err error)

TryAttrAs fetches an attribute of type T from an item.

It returns an error if the item is a different type.

Types

type RangeFunc added in v0.9.1

type RangeFunc func(context.Context, map[string]types.AttributeValue) (bool, error)

RangeFunc is a function that is called for each item in a result set.

Jump to

Keyboard shortcuts

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