database

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: GPL-3.0 Imports: 6 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteSingle added in v1.0.0

func DeleteSingle[T any](transportCtx context.Context, dynamoClient *dynamodb.Client, input *DeleteSingleInput) error

DeleteSingle deletes a single item from the database.

func GetMany added in v1.0.0

func GetMany[T any](transportCtx context.Context, dynamoClient *dynamodb.Client, input *GetManyInput) ([]T, error)

GetMany fetches items from the database and tries to deserialize it into a list of the provided struct type. Set the index to "" to query the main table. Set the limit to '-1' to fetch all items.

func GetSingle added in v1.0.0

func GetSingle[T any](transportCtx context.Context, dynamoClient *dynamodb.Client, input *GetSingleInput) (*T, error)

GetSingle fetches a single item from the database and tries to deserialize it into the provided struct type. Set the index to "" to query the main table.

func PutSingle added in v1.0.0

func PutSingle[T any](transportCtx context.Context, dynamoClient *dynamodb.Client, input *PutSingleInput[T]) error

PutSingle inserts a single item to the database. If you want to ensure no item is overwritten, you can set the ProtectionAttributeName to an attribute key that must NOT alread exist (usually the partition key is used for this).

func ScanMany added in v1.0.0

func ScanMany[T any](transportCtx context.Context, dynamoClient *dynamodb.Client, input *ScanManyInput) ([]T, error)

ScanMany reads all items from the database. Only use this on very very small datasets. Set the limit to '-1' to fetch all items.

func UpdateSingle added in v1.0.0

func UpdateSingle[T any](transportCtx context.Context, dynamoClient *dynamodb.Client, input *UpdateSingleInput) (*T, error)

UpdateSingle updates a single item on the database.

Types

type DeleteSingleInput added in v1.0.0

type DeleteSingleInput struct {
	Table      *string
	PrimaryKey map[string]dynamodbtypes.AttributeValue
}

type GetManyInput added in v1.0.0

type GetManyInput struct {
	Table           *string
	Index           *string
	AttributeValues map[string]dynamodbtypes.AttributeValue
	ConditionExpr   *string
	Limit           *int32
}

type GetSingleInput added in v1.0.0

type GetSingleInput struct {
	Table           *string
	Index           *string
	AttributeValues map[string]dynamodbtypes.AttributeValue
	ConditionExpr   *string
}

type PutSingleInput added in v1.0.0

type PutSingleInput[T any] struct {
	Table                   *string
	Item                    T
	ProtectionAttributeName *string
}

type ScanManyInput added in v1.0.0

type ScanManyInput struct {
	Table *string
	Limit *int32
}

type UpdateSingleInput added in v1.0.0

type UpdateSingleInput struct {
	Table           *string
	PrimaryKey      map[string]dynamodbtypes.AttributeValue
	Upsert          bool
	ReturnOld       bool
	ConditionExpr   *string
	AttributeNames  map[string]string
	AttributeValues map[string]dynamodbtypes.AttributeValue
	UpdateExpr      *string
}

Jump to

Keyboard shortcuts

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