dynamox

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package dynamox contains DynamoDB utilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	// True is a [types.AttributeValueMemberBOOL] for true.
	True = &types.AttributeValueMemberBOOL{Value: true}

	// False is a [types.AttributeValueMemberBOOL] for false.
	False = &types.AttributeValueMemberBOOL{Value: false}
)

Functions

func AsBool added in v0.10.0

func AsBool(
	item map[string]types.AttributeValue,
	name string,
) (bool, error)

AsBool fetches a boolean attribute from an item. It returns false if the item is absent.

func AsBytes added in v0.10.0

func AsBytes(
	item map[string]types.AttributeValue,
	name string,
) ([]byte, error)

AsBytes fetches a binary attribute from an item.

func AsNumericString added in v0.10.0

func AsNumericString(
	item map[string]types.AttributeValue,
	name string,
) (string, error)

AsNumericString fetches the string representation of a numeric attribute from an item.

func AsUint added in v0.10.0

func AsUint[T ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64](
	item map[string]types.AttributeValue,
	name string,
) (T, error)

AsUint fetches an unsigned integer attribute from an item.

func CreateTableIfNotExists added in v0.10.0

func CreateTableIfNotExists(
	ctx context.Context,
	client *dynamodb.Client,
	table string,
	onRequest func(any) []func(*dynamodb.Options),
	key ...KeyAttr,
) (bool, error)

CreateTableIfNotExists creates a DynamoDB table if it does not exist. It returns true if the table was created, or false if it already existed.

func DeleteTableIfExists added in v0.10.0

func DeleteTableIfExists(
	ctx context.Context,
	client *dynamodb.Client,
	table string,
	onRequest func(any) []func(*dynamodb.Options),
) error

DeleteTableIfExists deletes a DynamoDB table if it exists.

func NewTestClient

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

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

func QueryOne added in v0.10.0

func QueryOne(
	ctx context.Context,
	client *dynamodb.Client,
	m func(any) []func(*dynamodb.Options),
	in *dynamodb.QueryInput,
	fn func(context.Context, map[string]types.AttributeValue) error,
) (bool, error)

QueryOne executes a query and calls fn for the first item in the result set.

func QueryRange added in v0.10.0

func QueryRange(
	ctx context.Context,
	client *dynamodb.Client,
	m func(any) []func(*dynamodb.Options),
	in *dynamodb.QueryInput,
	fn func(context.Context, map[string]types.AttributeValue) (bool, error),
) error

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

Types

type KeyAttr added in v0.10.0

type KeyAttr struct {
	Name    *string
	Type    types.ScalarAttributeType
	KeyType types.KeyType
}

KeyAttr describes a key attribute of a DynamoDB table.

Jump to

Keyboard shortcuts

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