table

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package table provides the table instance for operations on the DynamoDB table.

Index

Constants

This section is empty.

Variables

View Source
var ErrItemNotFound = errors.New("dynamodb: item not found")

ErrItemNotFound will be returned when the item is not found.

Functions

This section is empty.

Types

type PrimaryKey

type PrimaryKey struct {
	types.AttributeDefinition
	types.KeySchemaElement
}

PrimaryKey represents primary key such as HASH and RANGE in DynamoDB.

type Table

type Table struct {
	DynamoDB *dynamodb.Client
	Name     *string
	// contains filtered or unexported fields
}

A Table represents a DynamoDB table.

func New

func New(ddbc *dynamodb.Client, name string) *Table

New returns Table instance with table name name and schema.

func (*Table) DeleteItem

func (t *Table) DeleteItem(ctx context.Context, hashKeyValue, rangeKeyValue types.AttributeValue, opts ...option.DeleteItemInputOption) error

DeleteItem deletes the item in the table.

func (*Table) GetItem

func (t *Table) GetItem(ctx context.Context, hashKeyValue, rangeKeyValue types.AttributeValue, v interface{}, opts ...option.GetItemInputOption) error

GetItem get the item from the table and convert it to v. It invokes attributevalue.UnmarshalMap function to unmarshal an item into v.

func (*Table) PutItem

func (t *Table) PutItem(ctx context.Context, v interface{}, opts ...option.PutItemInputOption) error

PutItem puts an item on the table. It invokes attributevalue.MarshalMap function to marshal v.

func (*Table) Query

func (t *Table) Query(ctx context.Context, slice interface{}, opts ...option.QueryInputOption) (map[string]types.AttributeValue, error)

Query queries items to the table and convert it to v. v must be a slice of struct. If the Query operation does not return the last page, LastEvaluatedKey will be returned.

func (*Table) UpdateItem

func (t *Table) UpdateItem(ctx context.Context, hashKeyValue, rangeKeyValue types.AttributeValue, opts ...option.UpdateItemInputOption) (*dynamodb.UpdateItemOutput, error)

UpdateItem updates the item on the table.

func (*Table) WithHashKey

func (t *Table) WithHashKey(keyName string, keyAttributeType types.ScalarAttributeType) *Table

WithHashKey specifies HASH key for the table. keyType must be "S", "N", or "B". See http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeDefinition.html

func (*Table) WithRangeKey

func (t *Table) WithRangeKey(keyName string, keyAttributeType types.ScalarAttributeType) *Table

WithRangeKey specifies RANGE key for the table. keyType must be "S", "N", or "B". See http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeDefinition.html

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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