database

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrQuery               = errors.New("error querying DynamoDB")
	ErrGetItem             = errors.New("error getting item from DynamoDB")
	ErrNoArguments         = errors.New("no arguments provided for query")
	ErrNoPlaceholders      = errors.New("number of placeholders does not match number of arguments")
	ErrConditionFormat     = errors.New("each condition must be in the format 'attribute = $index'")
	ErrPlaceholderFormat   = errors.New("placeholder must be in the format '$index'")
	ErrUnsupportedType     = errors.New("unsupported argument type")
	ErrGetItemKeyCondition = errors.New("GetItem requires exactly one key condition")
	ErrParameterNotPointer = errors.New("out parameter must be a pointer")
)

Functions

This section is empty.

Types

type Client

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

Client is an interface for the DynamoDB client.

func NewClient

func NewClient(db DynamoDBClient, tableName *string) *Client

NewClient returns a new DynamoDB client.

func (*Client) CreateItem

func (c *Client) CreateItem(ctx context.Context, in interface{}) (*dynamodb.PutItemOutput, error)

CreateItem handles creating a new item in the database.

func (*Client) DeleteItem

func (c *Client) DeleteItem(ctx context.Context, key interface{}) error

DeleteItem deletes an item from the database.

func (*Client) Find

func (c *Client) Find(ctx context.Context, out interface{}, query string, args ...interface{}) error

Find handles querying the database for items.

func (*Client) UpdateItem

func (c *Client) UpdateItem(ctx context.Context, key interface{}, updates map[string]interface{}) error

UpdateItem updates an existing item in the database.

type DynamoDBClient

type DynamoDBClient interface {
	PutItem(ctx context.Context, params *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
	Query(ctx context.Context, input *dynamodb.QueryInput, optFns ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)
	GetItem(ctx context.Context, params *dynamodb.GetItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, 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)
}

DynamoDBClient is an interface for the DynamoDB client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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