Documentation ¶
Overview ¶
Package table provides the table instance for operations on the DynamoDB table.
Index ¶
- Variables
- type PrimaryKey
- type Table
- func (t *Table) DeleteItem(ctx context.Context, hashKeyValue, rangeKeyValue types.AttributeValue, ...) error
- func (t *Table) GetItem(ctx context.Context, hashKeyValue, rangeKeyValue types.AttributeValue, ...) error
- func (t *Table) PutItem(ctx context.Context, v interface{}, opts ...option.PutItemInputOption) error
- func (t *Table) Query(ctx context.Context, slice interface{}, opts ...option.QueryInputOption) (map[string]types.AttributeValue, error)
- func (t *Table) UpdateItem(ctx context.Context, hashKeyValue, rangeKeyValue types.AttributeValue, ...) (*dynamodb.UpdateItemOutput, error)
- func (t *Table) WithHashKey(keyName string, keyAttributeType types.ScalarAttributeType) *Table
- func (t *Table) WithRangeKey(keyName string, keyAttributeType types.ScalarAttributeType) *Table
Constants ¶
This section is empty.
Variables ¶
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 (*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