Documentation
¶
Index ¶
- Constants
- func IsInvalidFieldNameError(err error) bool
- func IsItemNotFoundError(err error) bool
- func IsMismatchedValueCountError(err error) bool
- func TableName(eventSourceARN string) (string, bool)
- type Change
- type ConsumedCapacity
- type DDB
- func (d *DDB) MustTable(tableName string, model interface{}) *Table
- func (d *DDB) Table(tableName string, model interface{}) (*Table, error)
- func (d *DDB) TransactGetItems(items ...GetTx) error
- func (d *DDB) TransactGetItemsWithContext(ctx context.Context, gets ...GetTx) (err error)
- func (d *DDB) TransactWriteItems(items ...WriteTx) (*dynamodb.TransactWriteItemsOutput, error)
- func (d *DDB) TransactWriteItemsWithContext(ctx context.Context, items ...WriteTx) (*dynamodb.TransactWriteItemsOutput, error)
- func (d *DDB) WithTokenFunc(fn func() string) *DDB
- func (d *DDB) WithTransactAttempts(n int) *DDB
- func (d *DDB) WithTransactTimeout(fn func(i int) time.Duration) *DDB
- type Delete
- func (d *Delete) Condition(expr string, values ...interface{}) *Delete
- func (d *Delete) ConsumedCapacity(capture *ConsumedCapacity) *Delete
- func (d *Delete) DeleteItemInput() (*dynamodb.DeleteItemInput, error)
- func (d *Delete) Range(rangeKey interface{}) *Delete
- func (d *Delete) ReturnValuesOnConditionCheckFailure(value types.ReturnValuesOnConditionCheckFailure) *Delete
- func (d *Delete) Run() error
- func (d *Delete) RunWithContext(ctx context.Context) error
- func (d *Delete) Tx() (*types.TransactWriteItem, error)
- type DynamoDBAPI
- type EpochSeconds
- type Error
- type Event
- type Get
- func (g *Get) ConsistentRead(enabled bool) *Get
- func (g *Get) ConsumedCapacity(capture *ConsumedCapacity) *Get
- func (g *Get) GetItemInput() (*dynamodb.GetItemInput, error)
- func (g *Get) Range(value interface{}) *Get
- func (g *Get) Scan(v interface{}) error
- func (g *Get) ScanTx(v interface{}) GetTx
- func (g *Get) ScanWithContext(ctx context.Context, v interface{}) error
- type GetAPI
- type GetTx
- type Image
- type Int64Set
- type Item
- type Put
- func (p *Put) Condition(expr string, values ...interface{}) *Put
- func (p *Put) ConsumedCapacity(capture *ConsumedCapacity) *Put
- func (p *Put) PutItemInput() (*dynamodb.PutItemInput, error)
- func (p *Put) ReturnValuesOnConditionCheckFailure(value types.ReturnValuesOnConditionCheckFailure) *Put
- func (p *Put) Run() error
- func (p *Put) RunWithContext(ctx context.Context) error
- func (p *Put) Tx() (*types.TransactWriteItem, error)
- type PutAPI
- type Query
- func (q *Query) ConsistentRead(enabled bool) *Query
- func (q *Query) ConsumedCapacity(capture *ConsumedCapacity) *Query
- func (q *Query) Each(fn func(item Item) (bool, error)) error
- func (q *Query) EachWithContext(ctx context.Context, fn func(item Item) (bool, error)) (err error)
- func (q *Query) Filter(expr string, values ...interface{}) *Query
- func (q *Query) FindAll(v interface{}) error
- func (q *Query) FindAllWithContext(ctx context.Context, v interface{}) error
- func (q *Query) First(v interface{}) error
- func (q *Query) FirstWithContext(ctx context.Context, v interface{}) error
- func (q *Query) IndexName(indexName string) *Query
- func (q *Query) KeyCondition(expr string, values ...interface{}) *Query
- func (q *Query) LastEvaluatedKey(lastEvaluatedKey *map[string]types.AttributeValue) *Query
- func (q *Query) LastEvaluatedToken(lastEvaluatedToken *string) *Query
- func (q *Query) Limit(limit int64) *Query
- func (q *Query) QueryInput() (*dynamodb.QueryInput, error)
- func (q *Query) ScanIndexForward(enabled bool) *Query
- func (q *Query) Select(s types.Select) *Query
- func (q *Query) StartKey(startKey map[string]types.AttributeValue) *Query
- func (q *Query) StartToken(token string) *Query
- type Record
- type Scan
- func (s *Scan) ConsistentRead(enabled bool) *Scan
- func (s *Scan) ConsumedCapacity(capture *ConsumedCapacity) *Scan
- func (s *Scan) Debug(w io.Writer) *Scan
- func (s *Scan) Each(callback func(item Item) (bool, error)) error
- func (s *Scan) EachWithContext(ctx context.Context, callback func(item Item) (bool, error)) error
- func (s *Scan) Filter(expr string, values ...interface{}) *Scan
- func (s *Scan) First(v interface{}) error
- func (s *Scan) FirstWithContext(ctx context.Context, v interface{}) error
- func (s *Scan) IndexName(indexName string) *Scan
- func (s *Scan) TotalSegments(n int64) *Scan
- type StringSet
- func (ss StringSet) Contains(want string) bool
- func (ss StringSet) ContainsRegexp(re *regexp.Regexp) bool
- func (ss StringSet) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
- func (ss StringSet) StringSlice() []string
- func (ss StringSet) Sub(that StringSet) StringSet
- func (ss *StringSet) UnmarshalDynamoDBAttributeValue(item types.AttributeValue) error
- type Table
- func (t *Table) ConsumedCapacity() ConsumedCapacity
- func (t *Table) CreateTableIfNotExists(ctx context.Context, opts ...TableOption) error
- func (t *Table) DDB() *DDB
- func (t *Table) Delete(hashKey interface{}) *Delete
- func (t *Table) DeleteTableIfExists(ctx context.Context) error
- func (t *Table) Get(hashKey interface{}) *Get
- func (t *Table) Put(v interface{}) *Put
- func (t *Table) Query(expr string, values ...interface{}) *Query
- func (t *Table) Scan() *Scan
- func (t *Table) Update(hashKey interface{}) *Update
- type TableIndexOption
- type TableOption
- type Update
- func (u *Update) Add(expr string, values ...interface{}) *Update
- func (u *Update) Condition(expr string, values ...interface{}) *Update
- func (u *Update) ConsumedCapacity(capture *ConsumedCapacity) *Update
- func (u *Update) Delete(expr string, values ...interface{}) *Update
- func (u *Update) NewValues(v interface{}) *Update
- func (u *Update) OldValues(v interface{}) *Update
- func (u *Update) Range(rangeKey interface{}) *Update
- func (u *Update) Remove(expr string, values ...interface{}) *Update
- func (u *Update) ReturnValuesOnConditionCheckFailure(value types.ReturnValuesOnConditionCheckFailure) *Update
- func (u *Update) Run() error
- func (u *Update) RunWithContext(ctx context.Context) error
- func (u *Update) Set(expr string, values ...interface{}) *Update
- func (u *Update) Tx() (*types.TransactWriteItem, error)
- func (u *Update) UpdateItemInput() (*dynamodb.UpdateItemInput, error)
- type Window
- type WriteTx
Constants ¶
const ( // DefaultBillingMode specifies the default billing mode for DynamoDB tables as provisioned capacity DefaultBillingMode = types.BillingModeProvisioned // DefaultReadCapacity specifies the default read capacity units for provisioned tables DefaultReadCapacity = int64(3) // DefaultWriteCapacity specifies the default write capacity units for provisioned tables DefaultWriteCapacity = int64(3) )
const ( // ErrInvalidFieldName is returned when an invalid field name is specified in an expression ErrInvalidFieldName = "InvalidFieldName" // ErrItemNotFound is returned when a requested item does not exist in the table ErrItemNotFound = "ItemNotFound" // ErrMismatchedValueCount is returned when the number of values doesn't match placeholders in an expression ErrMismatchedValueCount = "MismatchedValueCount" // ErrUnableToMarshalItem is returned when an item cannot be marshaled to DynamoDB format ErrUnableToMarshalItem = "UnableToMarshalItem" )
const ( EventNameInsert = string(streamtypes.OperationTypeInsert) EventNameModify = string(streamtypes.OperationTypeModify) EventNameRemove = string(streamtypes.OperationTypeRemove) )
DynamoDB Streams event name constants (re-exported from AWS SDK for convenience)
Variables ¶
This section is empty.
Functions ¶
func IsInvalidFieldNameError ¶
IsInvalidFieldNameError returns true if any error in the cause chain contains the code ErrInvalidFieldName
func IsItemNotFoundError ¶
IsItemNotFoundError returns true if any error in the cause chain contains the code ErrItemNotFound
func IsMismatchedValueCountError ¶
IsMismatchedValueCountError returns true if any error in the cause chain contains the code ErrMismatchedValueCount
Types ¶
type Change ¶
type Change struct {
// The approximate date and time when the stream record was created, in UNIX
// epoch time (http://www.epochconverter.com/) format.
ApproximateCreationDateTime EpochSeconds `json:"ApproximateCreationDateTime,omitempty"`
// Keys for dynamodb modified dynamodb item
Keys Image `json:"Keys,omitempty"`
// NewImage holds dynamodb item AFTER modification
NewImage Image `json:"NewImage,omitempty"`
// OldImage holds dynamodb item BEFORE modification
OldImage Image `json:"OldImage,omitempty"`
// SequenceNumber of stream record
SequenceNumber string `json:"SequenceNumber"`
// SizeBytes contains size of record
SizeBytes int64 `json:"SizeBytes"`
// StreamViewType indicates what type of information is being held
// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_StreamSpecification.html
StreamViewType string `json:"StreamViewType"`
}
Change represents a modification to a DynamoDB item, including the keys, old image, and new image of the item.
type ConsumedCapacity ¶
type ConsumedCapacity struct {
ReadUnits int64
WriteUnits int64
// contains filtered or unexported fields
}
ConsumedCapacity tracks DynamoDB capacity units consumed by operations. It maintains separate counters for read and write capacity units, as well as total capacity units. The struct is safe for concurrent use.
func (*ConsumedCapacity) CapacityUnits ¶
func (c *ConsumedCapacity) CapacityUnits() float64
CapacityUnits returns the total capacity units consumed. This is thread-safe and returns the accumulated capacity units from operations that reported CapacityUnits (as opposed to ReadCapacityUnits or WriteCapacityUnits).
type DDB ¶
type DDB struct {
// contains filtered or unexported fields
}
DDB is the main entry point for DynamoDB operations. It wraps the AWS SDK DynamoDB client and provides a higher-level API with automatic schema inspection, expression parsing, and capacity tracking.
func New ¶
func New(api DynamoDBAPI) *DDB
New creates a new DDB instance with the provided DynamoDB API client. The client can be created using dynamodb.NewFromConfig(cfg) where cfg is obtained from config.LoadDefaultConfig().
func (*DDB) MustTable ¶
MustTable is like Table but panics if there is an error creating the table. Use this for initialization where the model schema is known to be valid.
func (*DDB) Table ¶
Table creates a Table instance for the specified table name and model. The model parameter should be a struct with DDB tags that define the table's hash key, range key, and indexes. Returns an error if the model cannot be inspected or has invalid schema tags.
func (*DDB) TransactGetItems ¶
TransactGetItems allows TransactGetItems to be called without a context
func (*DDB) TransactGetItemsWithContext ¶
TransactGetItemsWithContext wraps the get operations using a TransactGetItems
func (*DDB) TransactWriteItems ¶
func (d *DDB) TransactWriteItems(items ...WriteTx) (*dynamodb.TransactWriteItemsOutput, error)
TransactWriteItems executes a transactional write operation with multiple items. This is a convenience wrapper around TransactWriteItemsWithContext using the default context. See TransactWriteItemsWithContext for more details.
func (*DDB) TransactWriteItemsWithContext ¶
func (d *DDB) TransactWriteItemsWithContext(ctx context.Context, items ...WriteTx) (*dynamodb.TransactWriteItemsOutput, error)
TransactWriteItemsWithContext applies the provided operations in a dynamodb transaction. Subject to the limits of of TransactWriteItems.
func (*DDB) WithTokenFunc ¶
WithTokenFunc allows the generator func for dynamodb transactions to be overwritten
func (*DDB) WithTransactAttempts ¶
WithTransactAttempts overrides the number of times to attempt a Transact before giving up. Defaults to 4
type Delete ¶
type Delete struct {
// contains filtered or unexported fields
}
Delete represents a DynamoDB DeleteItem operation with support for conditions and consumed capacity tracking
func (*Delete) Condition ¶
Condition adds a condition expression to the delete operation. The expression uses placeholders (#field for attribute names, ? for values). Multiple conditions are combined with AND.
func (*Delete) ConsumedCapacity ¶
func (d *Delete) ConsumedCapacity(capture *ConsumedCapacity) *Delete
ConsumedCapacity captures consumed capacity to the property provided
func (*Delete) DeleteItemInput ¶
func (d *Delete) DeleteItemInput() (*dynamodb.DeleteItemInput, error)
DeleteItemInput constructs and returns the underlying DynamoDB DeleteItemInput that will be used for the delete operation
func (*Delete) Range ¶
Range specifies the range key value for the item to delete. This is required for tables that have a composite primary key.
func (*Delete) ReturnValuesOnConditionCheckFailure ¶
func (d *Delete) ReturnValuesOnConditionCheckFailure(value types.ReturnValuesOnConditionCheckFailure) *Delete
ReturnValuesOnConditionCheckFailure specifies what values to return when the delete condition fails. Valid values are types.ReturnValuesOnConditionCheckFailureNone and types.ReturnValuesOnConditionCheckFailureAllOld. This setting is only used when the delete is part of a transaction via Tx().
func (*Delete) Run ¶
Run executes the delete operation using the default context. Returns an error if the delete fails or if a condition is not met.
func (*Delete) RunWithContext ¶
RunWithContext executes the delete operation using the provided context. Returns an error if the delete fails or if a condition is not met.
type DynamoDBAPI ¶
type DynamoDBAPI interface {
GetItem(ctx context.Context, params *dynamodb.GetItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
PutItem(ctx context.Context, params *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
DeleteItem(ctx context.Context, params *dynamodb.DeleteItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DeleteItemOutput, error)
UpdateItem(ctx context.Context, params *dynamodb.UpdateItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.UpdateItemOutput, error)
Query(ctx context.Context, params *dynamodb.QueryInput, optFns ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)
Scan(ctx context.Context, params *dynamodb.ScanInput, optFns ...func(*dynamodb.Options)) (*dynamodb.ScanOutput, error)
TransactGetItems(ctx context.Context, params *dynamodb.TransactGetItemsInput, optFns ...func(*dynamodb.Options)) (*dynamodb.TransactGetItemsOutput, error)
TransactWriteItems(ctx context.Context, params *dynamodb.TransactWriteItemsInput, optFns ...func(*dynamodb.Options)) (*dynamodb.TransactWriteItemsOutput, error)
CreateTable(ctx context.Context, params *dynamodb.CreateTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.CreateTableOutput, error)
DeleteTable(ctx context.Context, params *dynamodb.DeleteTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DeleteTableOutput, error)
DescribeTable(ctx context.Context, params *dynamodb.DescribeTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DescribeTableOutput, error)
}
DynamoDBAPI defines the interface for DynamoDB operations
type EpochSeconds ¶
type EpochSeconds int64
EpochSeconds represents a timestamp as Unix seconds (seconds since January 1, 1970 UTC). This type is used for DynamoDB stream timestamps.
func (EpochSeconds) MarshalJSON ¶
func (e EpochSeconds) MarshalJSON() ([]byte, error)
MarshalJSON marshals EpochSeconds to JSON as a floating-point number. This implements the json.Marshaler interface.
func (EpochSeconds) Time ¶
func (e EpochSeconds) Time() time.Time
Time converts EpochSeconds to a time.Time value.
func (*EpochSeconds) UnmarshalJSON ¶
func (e *EpochSeconds) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals JSON into EpochSeconds from a floating-point number. This implements the json.Unmarshaler interface.
type Error ¶
type Error interface {
error
Cause() error
Code() string
Keys() (hashKey, rangeKey types.AttributeValue)
Message() string
TableName() string
}
Error provides a unified error definition that includes a code and message along with an optional original error.
type Event ¶
type Event struct {
// EventSourceARN holds the arn of the resource that generated the record
EventSourceARN string `json:"eventSourceARN,omitempty"`
// IsFinalInvokeForWindow - indicates if this is the last invocation for the tumbling window. This only occurs once per window period. [Tumbling Window]
IsFinalInvokeForWindow bool `json:"isFinalInvokeForWindow,omitempty"`
// IsWindowTerminatedEarly - a window ends early only if the state exceeds the maximum allowed size of 1 MB [Tumbling Window]
IsWindowTerminatedEarly bool `json:"isWindowTerminatedEarly,omitempty"`
// Records contains the modified records in order
Records []Record `json:"Records"`
// ShardId uniquely identifies the shard
ShardId string `json:"shardId,omitempty"`
// State holds optional tumbling window state [Tumbling Window]
State json.RawMessage `json:"state,omitempty"`
// Window holds the endpoints of this window [Tumbling Window]
Window *Window `json:"window,omitempty"`
}
Event represents a DynamoDB stream event that can be processed by AWS Lambda. This type addresses the incompatibility between github.com/aws/aws-lambda-go and github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue, allowing DynamoDB records to be properly unmarshaled.
type Get ¶
type Get struct {
// contains filtered or unexported fields
}
Get represents a DynamoDB GetItem operation with support for consistent reads and consumed capacity tracking
func (*Get) ConsistentRead ¶
ConsistentRead enables strongly consistent reads for the get operation. By default, DynamoDB uses eventually consistent reads which may not reflect recent writes.
func (*Get) ConsumedCapacity ¶
func (g *Get) ConsumedCapacity(capture *ConsumedCapacity) *Get
ConsumedCapacity captures consumed capacity to the property provided
func (*Get) GetItemInput ¶
func (g *Get) GetItemInput() (*dynamodb.GetItemInput, error)
GetItemInput constructs and returns the underlying DynamoDB GetItemInput that will be used for the get operation
func (*Get) Range ¶
Range specifies the range key value for the item to retrieve. This is required for tables that have a composite primary key.
func (*Get) Scan ¶
Scan retrieves the item and unmarshals it into the provided value using the default context. Returns ErrItemNotFound if the item does not exist.
type GetAPI ¶
type GetAPI interface {
GetItem(ctx context.Context, params *dynamodb.GetItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
}
GetAPI defines the interface for Get operations
type GetTx ¶
type GetTx interface {
// Decode the response from AWS
Decode(v *types.ItemResponse) error
// Tx generates the get input
Tx() (*types.TransactGetItem, error)
}
GetTx encapsulates a transactional get operation
type Image ¶ added in v2.0.3
type Image map[string]types.AttributeValue
Image represents a DynamoDB item (a map of attribute names to values). This type properly unmarshals AttributeValue data from JSON stream events.
func (*Image) UnmarshalJSON ¶ added in v2.0.3
UnmarshalJSON implements custom JSON unmarshaling for DynamoDB AttributeValue maps.
type Int64Set ¶
type Int64Set []int64
Int64Set represents a DynamoDB Number Set (NS) type, storing a collection of int64 values. This is distinct from a List (L) type which would be the default for slices.
func (Int64Set) MarshalDynamoDBAttributeValue ¶
func (ii Int64Set) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
MarshalDynamoDBAttributeValue marshals the Int64Set into a DynamoDB Number Set attribute. This implements the Marshaler interface for the AWS SDK v2.
func (*Int64Set) UnmarshalDynamoDBAttributeValue ¶
func (ii *Int64Set) UnmarshalDynamoDBAttributeValue(item types.AttributeValue) error
UnmarshalDynamoDBAttributeValue unmarshals a DynamoDB Number Set attribute into an Int64Set. This implements the Unmarshaler interface for the AWS SDK v2.
type Item ¶
type Item interface {
// Raw returns the raw value of the element
Raw() map[string]types.AttributeValue
// Unmarshal the record into the provided interface
Unmarshal(v interface{}) error
}
Item provides handle to each record that can be unmarshalled
type Put ¶
type Put struct {
// contains filtered or unexported fields
}
Put represents a DynamoDB PutItem operation with support for conditions and consumed capacity tracking
func (*Put) Condition ¶
Condition adds a condition expression to the put operation. The expression uses placeholders (#field for attribute names, ? for values). Multiple conditions are combined with AND.
func (*Put) ConsumedCapacity ¶
func (p *Put) ConsumedCapacity(capture *ConsumedCapacity) *Put
ConsumedCapacity captures consumed capacity to the property provided
func (*Put) PutItemInput ¶
func (p *Put) PutItemInput() (*dynamodb.PutItemInput, error)
PutItemInput constructs and returns the underlying DynamoDB PutItemInput that will be used for the put operation
func (*Put) ReturnValuesOnConditionCheckFailure ¶
func (p *Put) ReturnValuesOnConditionCheckFailure(value types.ReturnValuesOnConditionCheckFailure) *Put
ReturnValuesOnConditionCheckFailure specifies what values to return when the put condition fails. Valid values are types.ReturnValuesOnConditionCheckFailureNone and types.ReturnValuesOnConditionCheckFailureAllOld. This setting is only used when the put is part of a transaction via Tx().
func (*Put) Run ¶
Run executes the put operation using the default context. Returns an error if the put fails or if a condition is not met.
func (*Put) RunWithContext ¶
RunWithContext executes the put operation using the provided context. Returns an error if the put fails or if a condition is not met.
type PutAPI ¶
type PutAPI interface {
PutItem(ctx context.Context, params *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
}
PutAPI defines the interface for Put operations
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query represents a DynamoDB Query operation with support for filtering, pagination, and consumed capacity tracking
func (*Query) ConsistentRead ¶
ConsistentRead enables strongly consistent reads for the query operation. By default, DynamoDB uses eventually consistent reads which may not reflect recent writes.
func (*Query) ConsumedCapacity ¶
func (q *Query) ConsumedCapacity(capture *ConsumedCapacity) *Query
ConsumedCapacity captures consumed capacity to the property provided
func (*Query) Each ¶
Each iterates over all items matching the query, invoking the callback for each. The callback should return true to continue iteration or false to stop.
func (*Query) EachWithContext ¶
EachWithContext iterates over all items matching the query using the provided context. The callback should return true to continue iteration or false to stop.
func (*Query) FindAllWithContext ¶
FindAllWithContext returns all record using context provided
func (*Query) FirstWithContext ¶
FirstWithContext binds the first value and returns
func (*Query) IndexName ¶
IndexName specifies the name of a secondary index to query. If not specified, the query operates on the base table.
func (*Query) KeyCondition ¶
KeyCondition sets the key condition expression for the query. The expression uses placeholders (#field for attribute names, ? for values).
func (*Query) LastEvaluatedKey ¶
func (q *Query) LastEvaluatedKey(lastEvaluatedKey *map[string]types.AttributeValue) *Query
LastEvaluatedKey stores the last evaluated key into the provided value
func (*Query) LastEvaluatedToken ¶
LastEvaluatedToken stores the last evaluated key as a base64 encoded string
func (*Query) QueryInput ¶
func (q *Query) QueryInput() (*dynamodb.QueryInput, error)
QueryInput constructs and returns the underlying DynamoDB QueryInput that will be submitted to DynamoDB
func (*Query) ScanIndexForward ¶
ScanIndexForward when true returns the values in reverse sort key order https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html
func (*Query) Select ¶
Select specifies which attributes to return. Defaults to types.SelectAllAttributes if not specified.
func (*Query) StartKey ¶
func (q *Query) StartKey(startKey map[string]types.AttributeValue) *Query
StartKey sets the exclusive start key for query pagination. Use the last evaluated key from a previous query to continue pagination.
func (*Query) StartToken ¶
StartToken sets the exclusive start key using a base64 encoded token. This provides a more portable way to handle pagination than raw keys.
type Record ¶
type Record struct {
// AWSRegion update occurred within
AWSRegion string `json:"awsRegion"`
// Change holds the modification to the dynamodb record
Change Change `json:"dynamodb"`
// EventID holds a unique identifier for event
EventID string `json:"eventID"`
// EventName will be one of INSERT, MODIFY, or REMOVE
// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_Record.html
EventName string `json:"eventName"`
// EventSource for record. Will generally be aws:dynamodb
EventSource string `json:"eventSource"`
// EventSourceARN holds the arn of the resource that generated the record
EventSourceARN string `json:"eventSourceARN"`
// EventVersion number of the stream format
EventVersion string `json:"eventVersion"`
}
Record represents a single DynamoDB stream record containing metadata about a change to an item in the table.
type Scan ¶
type Scan struct {
// contains filtered or unexported fields
}
Scan represents a DynamoDB Scan operation with support for parallel scanning, filtering, and consumed capacity tracking
func (*Scan) ConsistentRead ¶
ConsistentRead enables or disables consistent reading
func (*Scan) ConsumedCapacity ¶
func (s *Scan) ConsumedCapacity(capture *ConsumedCapacity) *Scan
ConsumedCapacity captures consumed capacity to the property provided
func (*Scan) Each ¶
Each is identical to EachWithContext except that it does not allow for cancellation via the context.
func (*Scan) EachWithContext ¶
EachWithContext iterates invokes the callback for each record that matches the scan. So long as the callback returns `true, nil`, the scan will continue. If the callback either returns an error OR false, the scan will stop. The scan will also stop if the context has been canceled.
func (*Scan) FirstWithContext ¶
FirstWithContext returns the first scanned record and allows for cancellation
func (*Scan) IndexName ¶
IndexName specifies the name of a secondary index to scan. If not specified, the scan operates on the base table.
func (*Scan) TotalSegments ¶
TotalSegments enables parallel scanning by dividing the table into segments. Each segment is scanned concurrently. Defaults to 1 (sequential scan).
type StringSet ¶
type StringSet []string
StringSet represents a DynamoDB String Set (SS) type, storing a collection of string values. This is distinct from a List (L) type which would be the default for slices.
func (StringSet) Contains ¶
Contains returns true if the specified string is found in the StringSet.
func (StringSet) ContainsRegexp ¶
ContainsRegexp returns true if the provided regular expression matches any element in the StringSet.
func (StringSet) MarshalDynamoDBAttributeValue ¶
func (ss StringSet) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
MarshalDynamoDBAttributeValue marshals the StringSet into a DynamoDB String Set attribute. This implements the Marshaler interface for the AWS SDK v2.
func (StringSet) StringSlice ¶
StringSlice converts the StringSet to a standard []string slice.
func (StringSet) Sub ¶
Sub returns a new StringSet containing elements from the original set that are not present in the provided set (set difference operation).
func (*StringSet) UnmarshalDynamoDBAttributeValue ¶
func (ss *StringSet) UnmarshalDynamoDBAttributeValue(item types.AttributeValue) error
UnmarshalDynamoDBAttributeValue unmarshals a DynamoDB String Set attribute into a StringSet. This implements the Unmarshaler interface for the AWS SDK v2.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents a DynamoDB table and provides methods for CRUD operations. It maintains table metadata and tracks consumed capacity for all operations performed on the table.
func (*Table) ConsumedCapacity ¶
func (t *Table) ConsumedCapacity() ConsumedCapacity
ConsumedCapacity returns a snapshot of the capacity units consumed by all operations performed on this table. The returned value is a copy and safe to use without synchronization.
func (*Table) CreateTableIfNotExists ¶
func (t *Table) CreateTableIfNotExists(ctx context.Context, opts ...TableOption) error
CreateTableIfNotExists creates a DynamoDB table if it does not already exist. If the table already exists, this method returns nil without error. Options can be provided to configure billing mode, capacity, and stream settings.
func (*Table) Delete ¶
Delete creates a new Delete operation for the item with the specified hash key. Use Range() to specify the range key if the table has a composite primary key.
func (*Table) DeleteTableIfExists ¶
DeleteTableIfExists deletes a DynamoDB table if it exists. If the table does not exist, this method returns nil without error.
func (*Table) Get ¶
Get creates a new Get operation for the item with the specified hash key. Use Range() to specify the range key if the table has a composite primary key.
func (*Table) Put ¶
Put creates a new Put operation to insert or replace the specified item in the table. The item will be marshaled to DynamoDB format automatically.
func (*Table) Query ¶
Query creates a new Query operation with the specified key condition expression. The expression uses placeholders (#field for attribute names, ? for values). Use IndexName() to query a secondary index instead of the base table.
type TableIndexOption ¶
type TableIndexOption interface {
TableOption
}
TableIndexOption defines an interface for options that can be applied to both tables and indexes
func WithReadCapacity ¶
func WithReadCapacity(rcap int64) TableIndexOption
WithReadCapacity sets the read capacity units for provisioned tables and indexes. This setting is only used when billing mode is set to provisioned capacity.
func WithWriteCapacity ¶
func WithWriteCapacity(wcap int64) TableIndexOption
WithWriteCapacity sets the write capacity units for provisioned tables and indexes. This setting is only used when billing mode is set to provisioned capacity.
type TableOption ¶
type TableOption interface {
ApplyTable(o *tableOptions)
}
TableOption defines an interface for applying configuration options to table creation
func WithBillingMode ¶
func WithBillingMode(mode types.BillingMode) TableOption
WithBillingMode configures the billing mode for a DynamoDB table. Common modes are types.BillingModeProvisioned and types.BillingModePayPerRequest.
func WithStreamSpecification ¶
func WithStreamSpecification(streamViewType string) TableOption
WithStreamSpecification enables DynamoDB streams for the table with the specified view type. Valid values include KEYS_ONLY, NEW_IMAGE, OLD_IMAGE, and NEW_AND_OLD_IMAGES.
type Update ¶
type Update struct {
// contains filtered or unexported fields
}
Update represents a DynamoDB UpdateItem operation with support for SET, ADD, DELETE, REMOVE expressions, conditions, and consumed capacity tracking
func (*Update) Add ¶
Add increments a number attribute or adds elements to a set attribute. For numbers, adds the specified value. For sets, adds the specified elements.
func (*Update) Condition ¶
Condition adds a condition expression to the update operation. Multiple conditions are combined with AND. The update only succeeds if all conditions are met.
func (*Update) ConsumedCapacity ¶
func (u *Update) ConsumedCapacity(capture *ConsumedCapacity) *Update
ConsumedCapacity captures consumed capacity information to the provided variable.
func (*Update) Delete ¶
Delete removes elements from a set attribute. The specified elements are removed from the set.
func (*Update) NewValues ¶
NewValues captures the updated attribute values after the update completes. The provided variable will be populated with the new values.
func (*Update) OldValues ¶
OldValues captures the original attribute values before the update. The provided variable will be populated with the old values.
func (*Update) Range ¶
Range specifies the range key value for the item to update. This is required for tables that have a composite primary key.
func (*Update) Remove ¶
Remove deletes an attribute from the item. The specified attributes are completely removed from the item.
func (*Update) ReturnValuesOnConditionCheckFailure ¶
func (u *Update) ReturnValuesOnConditionCheckFailure(value types.ReturnValuesOnConditionCheckFailure) *Update
ReturnValuesOnConditionCheckFailure specifies what values to return when the update condition fails. Valid values are types.ReturnValuesOnConditionCheckFailureNone and types.ReturnValuesOnConditionCheckFailureAllOld. This setting is only used when the update is part of a transaction via Tx().
func (*Update) Run ¶
Run executes the update operation using the default context. Returns an error if the update fails or if a condition is not met.
func (*Update) RunWithContext ¶
RunWithContext executes the update operation using the provided context. Returns an error if the update fails or if a condition is not met.
func (*Update) Set ¶
Set sets the value of an attribute or creates a new attribute if it doesn't exist. This is the most common update operation for modifying attribute values.
func (*Update) Tx ¶
func (u *Update) Tx() (*types.TransactWriteItem, error)
Tx converts the update operation into a TransactWriteItem for use in transactions. Returns an error if the update configuration is invalid.
func (*Update) UpdateItemInput ¶
func (u *Update) UpdateItemInput() (*dynamodb.UpdateItemInput, error)
UpdateItemInput constructs and returns the underlying DynamoDB UpdateItemInput that will be used for the update operation
type Window ¶
Window represents a tumbling window for Lambda stream processing. See https://aws.amazon.com/blogs/compute/using-aws-lambda-for-streaming-analytics/
type WriteTx ¶
type WriteTx interface {
Tx() (*types.TransactWriteItem, error)
}
WriteTx converts ddb operations into instances of *types.TransactWriteItem