query

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package query provides aggregate functionality for DynamoDB queries

Package query provides enhanced batch operations for DynamoDB

Package query provides update builder functionality for DynamoDB

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeCursor

func EncodeCursor(lastKey map[string]types.AttributeValue, indexName string, sortDirection string) (string, error)

EncodeCursor encodes a DynamoDB LastEvaluatedKey into a base64 cursor string

Types

type AggregateResult

type AggregateResult struct {
	Count   int64
	Sum     float64
	Average float64
	Min     any
	Max     any
}

AggregateResult holds the result of an aggregate operation

type BatchExecutor

type BatchExecutor interface {
	QueryExecutor
	ExecuteBatchGet(input *CompiledBatchGet, dest any) error
	ExecuteBatchWrite(input *CompiledBatchWrite) error
}

BatchExecutor extends QueryExecutor with batch operations

type BatchGetResult

type BatchGetResult struct {
	Responses       []map[string]types.AttributeValue
	UnprocessedKeys []map[string]types.AttributeValue
}

BatchGetResult represents the result of a batch get operation

type BatchResult

type BatchResult struct {
	Succeeded       int
	Failed          int
	UnprocessedKeys []any
	Errors          []error
}

BatchResult represents the result of a batch operation

type BatchUpdateOptions

type BatchUpdateOptions struct {
	// MaxBatchSize limits items per batch (max 25 for DynamoDB)
	MaxBatchSize int
	// Parallel enables parallel batch execution
	Parallel bool
	// MaxConcurrency limits concurrent batches
	MaxConcurrency int
	// ProgressCallback is called after each batch
	ProgressCallback func(processed, total int)
	// ErrorHandler handles individual item errors
	ErrorHandler func(item any, err error) error
	// RetryPolicy defines retry behavior
	RetryPolicy *RetryPolicy
}

BatchUpdateOptions configures batch update operations

func DefaultBatchOptions

func DefaultBatchOptions() *BatchUpdateOptions

DefaultBatchOptions returns default batch options

type BatchWriteItemExecutor

type BatchWriteItemExecutor interface {
	QueryExecutor
	ExecuteBatchWriteItem(tableName string, writeRequests []types.WriteRequest) (*core.BatchWriteResult, error)
}

BatchWriteItemExecutor extends QueryExecutor with BatchWriteItem support

type CompiledBatchGet

type CompiledBatchGet struct {
	TableName                string
	Keys                     []map[string]types.AttributeValue
	ProjectionExpression     string
	ExpressionAttributeNames map[string]string
	ConsistentRead           bool
}

CompiledBatchGet represents a compiled batch get operation

type CompiledBatchWrite

type CompiledBatchWrite struct {
	TableName string
	Items     []map[string]types.AttributeValue
}

CompiledBatchWrite represents a compiled batch write operation

type CompiledScan

type CompiledScan struct {
	TableName                 string
	FilterExpression          string
	ProjectionExpression      string
	ExpressionAttributeNames  map[string]string
	ExpressionAttributeValues map[string]types.AttributeValue
	Limit                     *int32
	ExclusiveStartKey         map[string]types.AttributeValue
	ConsistentRead            bool
	Segment                   *int32
	TotalSegments             *int32
}

CompiledScan represents a compiled scan operation

type Condition

type Condition struct {
	Field    string
	Operator string
	Value    any
}

Condition represents a query condition

type CostEstimate

type CostEstimate struct {
	ReadCapacityUnits  float64
	WriteCapacityUnits float64
	EstimatedItemCount int64
	EstimatedScanCount int64
	EstimatedDuration  time.Duration
	ConfidenceLevel    float64 // 0.0 to 1.0
}

CostEstimate represents the estimated cost of a query

type Cursor

type Cursor struct {
	LastEvaluatedKey map[string]any `json:"lastKey"`
	IndexName        string         `json:"index,omitempty"`
	SortDirection    string         `json:"sort,omitempty"`
}

Cursor represents pagination state for DynamoDB queries

func DecodeCursor

func DecodeCursor(encoded string) (*Cursor, error)

DecodeCursor decodes a base64 cursor string into a Cursor

func (*Cursor) ToAttributeValues

func (c *Cursor) ToAttributeValues() (map[string]types.AttributeValue, error)

ToAttributeValues converts the cursor's LastEvaluatedKey back to DynamoDB AttributeValues

type DeleteItemExecutor

type DeleteItemExecutor interface {
	QueryExecutor
	ExecuteDeleteItem(input *core.CompiledQuery, key map[string]types.AttributeValue) error
}

DeleteItemExecutor extends QueryExecutor with DeleteItem support

type DynamoDBAPI

type DynamoDBAPI interface {
	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)
	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)
	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)
	BatchGetItem(ctx context.Context, params *dynamodb.BatchGetItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.BatchGetItemOutput, error)
	BatchWriteItem(ctx context.Context, params *dynamodb.BatchWriteItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.BatchWriteItemOutput, error)
}

DynamoDBAPI defines the interface for all DynamoDB operations

type Filter

type Filter struct {
	Expression string
	Params     map[string]any
}

Filter represents a filter expression

type GroupByQuery

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

GroupByQuery enables chaining aggregate operations on grouped data

func (*GroupByQuery) Avg

func (g *GroupByQuery) Avg(field, alias string) *GroupByQuery

Avg adds an AVG aggregate on a field

func (*GroupByQuery) Count

func (g *GroupByQuery) Count(alias string) *GroupByQuery

Count adds a COUNT aggregate

func (*GroupByQuery) Execute

func (g *GroupByQuery) Execute() ([]*GroupedResult, error)

Execute runs the group by query and returns results

func (*GroupByQuery) Having

func (g *GroupByQuery) Having(aggregate, operator string, value any) *GroupByQuery

Having adds a HAVING clause to filter groups

func (*GroupByQuery) Max

func (g *GroupByQuery) Max(field, alias string) *GroupByQuery

Max adds a MAX aggregate on a field

func (*GroupByQuery) Min

func (g *GroupByQuery) Min(field, alias string) *GroupByQuery

Min adds a MIN aggregate on a field

func (*GroupByQuery) Sum

func (g *GroupByQuery) Sum(field, alias string) *GroupByQuery

Sum adds a SUM aggregate on a field

type GroupedResult

type GroupedResult struct {
	Key        any
	Count      int64
	Items      []any
	Aggregates map[string]*AggregateResult
}

GroupBy groups results by a field and performs aggregate operations

type MainExecutor

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

MainExecutor is the main executor that implements all executor interfaces

func NewExecutor

func NewExecutor(client DynamoDBAPI, ctx context.Context) *MainExecutor

NewExecutor creates a new MainExecutor instance

func (*MainExecutor) ExecuteBatchGet

func (e *MainExecutor) ExecuteBatchGet(input *CompiledBatchGet, dest any) error

ExecuteBatchGet implements BatchExecutor.ExecuteBatchGet

func (*MainExecutor) ExecuteBatchWrite

func (e *MainExecutor) ExecuteBatchWrite(input *CompiledBatchWrite) error

ExecuteBatchWrite implements BatchExecutor.ExecuteBatchWrite

func (*MainExecutor) ExecuteDeleteItem

func (e *MainExecutor) ExecuteDeleteItem(input *core.CompiledQuery, key map[string]types.AttributeValue) error

ExecuteDeleteItem implements DeleteItemExecutor.ExecuteDeleteItem

func (*MainExecutor) ExecutePutItem

func (e *MainExecutor) ExecutePutItem(input *core.CompiledQuery, item map[string]types.AttributeValue) error

ExecutePutItem implements PutItemExecutor.ExecutePutItem

func (*MainExecutor) ExecuteQuery

func (e *MainExecutor) ExecuteQuery(input *core.CompiledQuery, dest any) error

ExecuteQuery implements QueryExecutor.ExecuteQuery

func (*MainExecutor) ExecuteQueryWithPagination

func (e *MainExecutor) ExecuteQueryWithPagination(input *core.CompiledQuery, dest any) (*QueryResult, error)

ExecuteQueryWithPagination implements PaginatedQueryExecutor.ExecuteQueryWithPagination

func (*MainExecutor) ExecuteScan

func (e *MainExecutor) ExecuteScan(input *core.CompiledQuery, dest any) error

ExecuteScan implements QueryExecutor.ExecuteScan

func (*MainExecutor) ExecuteScanWithPagination

func (e *MainExecutor) ExecuteScanWithPagination(input *core.CompiledQuery, dest any) (*ScanResult, error)

ExecuteScanWithPagination implements PaginatedQueryExecutor.ExecuteScanWithPagination

func (*MainExecutor) ExecuteUpdateItem

func (e *MainExecutor) ExecuteUpdateItem(input *core.CompiledQuery, key map[string]types.AttributeValue) error

ExecuteUpdateItem implements UpdateItemExecutor.ExecuteUpdateItem

func (*MainExecutor) ExecuteUpdateItemWithResult

func (e *MainExecutor) ExecuteUpdateItemWithResult(input *core.CompiledQuery, key map[string]types.AttributeValue) (*core.UpdateResult, error)

ExecuteUpdateItemWithResult implements UpdateItemWithResultExecutor.ExecuteUpdateItemWithResult

type OptimizationOptions

type OptimizationOptions struct {
	EnableAdaptive bool
	EnableParallel bool
	MaxParallelism int
	PlanCacheTTL   time.Duration
	MaxCacheSize   int
}

OptimizationOptions configures the optimizer behavior

type OptimizedQuery

type OptimizedQuery struct {
	*Query
	// contains filtered or unexported fields
}

OptimizedQuery wraps a Query with optimization capabilities

func (*OptimizedQuery) Execute

func (oq *OptimizedQuery) Execute(dest any) error

Execute executes the query with optimizations applied

func (*OptimizedQuery) ExplainPlan

func (oq *OptimizedQuery) ExplainPlan() string

ExplainPlan returns a human-readable explanation of the query plan

func (*OptimizedQuery) GetPlan

func (oq *OptimizedQuery) GetPlan() *QueryPlan

GetPlan returns the optimization plan

type OrderBy

type OrderBy struct {
	Field string
	Order string // "asc" or "desc"
}

OrderBy represents ordering configuration

type PaginatedQueryExecutor

type PaginatedQueryExecutor interface {
	QueryExecutor
	ExecuteQueryWithPagination(input *core.CompiledQuery, dest any) (*QueryResult, error)
	ExecuteScanWithPagination(input *core.CompiledQuery, dest any) (*ScanResult, error)
}

PaginatedQueryExecutor extends QueryExecutor with pagination support

type PaginatedResult

type PaginatedResult struct {
	Items        any    `json:"items"`
	NextCursor   string `json:"nextCursor,omitempty"`
	Count        int    `json:"count"`
	HasMore      bool   `json:"hasMore"`
	ScannedCount int    `json:"scannedCount,omitempty"`
}

PaginatedResult represents a paginated query result

type PutItemExecutor

type PutItemExecutor interface {
	QueryExecutor
	ExecutePutItem(input *core.CompiledQuery, item map[string]types.AttributeValue) error
}

PutItemExecutor extends QueryExecutor with PutItem support

type Query

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

Query represents a DynamoDB query builder

func New

func New(model any, metadata core.ModelMetadata, executor QueryExecutor) *Query

New creates a new Query instance

func (*Query) Aggregate

func (q *Query) Aggregate(fields ...string) (*AggregateResult, error)

Aggregate performs multiple aggregate operations in a single pass

func (*Query) All

func (q *Query) All(dest any) error

All executes the query and returns all results

func (*Query) AllPaginated

func (q *Query) AllPaginated(dest any) (*core.PaginatedResult, error)

AllPaginated executes the query and returns paginated results

func (*Query) Average

func (q *Query) Average(field string) (float64, error)

Average calculates the average of a numeric field

func (*Query) BatchCreate

func (q *Query) BatchCreate(items any) error

BatchCreate creates multiple items

func (*Query) BatchCreateWithResult

func (q *Query) BatchCreateWithResult(items any) (*BatchResult, error)

BatchCreateWithResult creates multiple items and returns detailed results

func (*Query) BatchDelete

func (q *Query) BatchDelete(keys []any) error

BatchDelete performs batch delete operations

func (*Query) BatchDeleteWithOptions

func (q *Query) BatchDeleteWithOptions(keys []any, opts *BatchUpdateOptions) error

BatchDeleteWithOptions performs batch delete with custom options

func (*Query) BatchGet

func (q *Query) BatchGet(keys []any, dest any) error

BatchGet retrieves multiple items by their primary keys

func (*Query) BatchUpdate

func (q *Query) BatchUpdate(items any, fields ...string) error

BatchUpdate performs batch update operations

func (*Query) BatchUpdateWithOptions

func (q *Query) BatchUpdateWithOptions(items []any, fields []string, options ...any) error

BatchUpdateWithOptions implements core.Query interface with the expected signature

func (*Query) BatchWrite

func (q *Query) BatchWrite(putItems []any, deleteKeys []any) error

BatchWrite performs mixed batch write operations (puts and deletes)

func (*Query) BatchWriteWithOptions

func (q *Query) BatchWriteWithOptions(putItems []any, deleteKeys []any, opts *BatchUpdateOptions) error

BatchWriteWithOptions performs mixed batch write operations with custom options

func (*Query) Compile

func (q *Query) Compile() (*core.CompiledQuery, error)

Compile compiles the query into executable form

func (*Query) Count

func (q *Query) Count() (int64, error)

Count returns the count of matching items

func (*Query) CountDistinct

func (q *Query) CountDistinct(field string) (int64, error)

CountDistinct counts unique values for a field

func (*Query) Create

func (q *Query) Create() error

Create creates a new item

func (*Query) CreateOrUpdate added in v1.0.5

func (q *Query) CreateOrUpdate() error

CreateOrUpdate creates a new item or updates an existing one (upsert)

func (*Query) Cursor

func (q *Query) Cursor(cursor string) core.Query

Cursor is a fluent method to set the pagination cursor

func (*Query) Delete

func (q *Query) Delete() error

Delete deletes an item

func (*Query) Filter

func (q *Query) Filter(field string, op string, value any) core.Query

Filter adds a filter expression to the query

func (*Query) FilterGroup

func (q *Query) FilterGroup(fn func(core.Query)) core.Query

FilterGroup adds a grouped AND filter condition

func (*Query) First

func (q *Query) First(dest any) error

First executes the query and returns the first result

func (*Query) GroupBy

func (q *Query) GroupBy(field string) *GroupByQuery

GroupBy groups items by a field

func (*Query) Having

func (q *Query) Having(condition string, value any) core.Query

Having is deprecated - use GroupBy().Having() instead for proper aggregate filtering This method is kept for backward compatibility but does nothing

func (*Query) Index

func (q *Query) Index(name string) core.Query

Index specifies which index to use

func (*Query) Limit

func (q *Query) Limit(n int) core.Query

Limit sets the maximum number of items to return

func (*Query) Max

func (q *Query) Max(field string) (any, error)

Max finds the maximum value of a field

func (*Query) Min

func (q *Query) Min(field string) (any, error)

Min finds the minimum value of a field

func (*Query) Offset

func (q *Query) Offset(offset int) core.Query

Offset sets the starting position for the query

func (*Query) OrFilter

func (q *Query) OrFilter(field string, op string, value any) core.Query

OrFilter adds an OR filter condition

func (*Query) OrFilterGroup

func (q *Query) OrFilterGroup(fn func(core.Query)) core.Query

OrFilterGroup adds a grouped OR filter condition

func (*Query) OrderBy

func (q *Query) OrderBy(field string, order string) core.Query

OrderBy sets the sort order

func (*Query) ParallelScan

func (q *Query) ParallelScan(segment int32, totalSegments int32) core.Query

ParallelScan performs a parallel table scan with the specified segment

func (*Query) QueryTimeout

func (q *Query) QueryTimeout(timeout time.Duration) core.Query

QueryTimeout sets a timeout for the query execution

func (*Query) Scan

func (q *Query) Scan(dest any) error

Scan performs a table scan

func (*Query) ScanAllSegments

func (q *Query) ScanAllSegments(dest any, totalSegments int32) error

ScanAllSegments performs a parallel scan across all segments and combines results

func (*Query) Select

func (q *Query) Select(fields ...string) core.Query

Select specifies which fields to return

func (*Query) SetCursor

func (q *Query) SetCursor(cursor string) error

SetCursor sets the pagination cursor for the query

func (*Query) Sum

func (q *Query) Sum(field string) (float64, error)

Sum calculates the sum of a numeric field

func (*Query) Update

func (q *Query) Update(fields ...string) error

Update updates specified fields on an item

func (*Query) UpdateBuilder

func (q *Query) UpdateBuilder() core.UpdateBuilder

NewUpdateBuilder creates a new update builder for the query

func (*Query) Where

func (q *Query) Where(field string, op string, value any) core.Query

Where adds a condition to the query

func (*Query) WithCancellation

func (q *Query) WithCancellation() (core.Query, *QueryCanceler)

WithCancellation returns a query that can be cancelled

func (*Query) WithContext

func (q *Query) WithContext(ctx context.Context) core.Query

WithContext sets the context for the query

func (*Query) WithOptimizer

func (q *Query) WithOptimizer(optimizer *QueryOptimizer) (*OptimizedQuery, error)

WithOptimizer creates an optimized query wrapper

type QueryCanceler

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

QueryCancel provides a way to cancel long-running queries

func (*QueryCanceler) Cancel

func (qc *QueryCanceler) Cancel()

Cancel cancels the query execution

type QueryExecutionResult

type QueryExecutionResult struct {
	Duration      time.Duration
	ItemsReturned int64
	ItemsScanned  int64
	Error         error
}

QueryExecutionResult represents the result of a query execution

type QueryExecutor

type QueryExecutor interface {
	ExecuteQuery(input *core.CompiledQuery, dest any) error
	ExecuteScan(input *core.CompiledQuery, dest any) error
}

QueryExecutor is the base query executor interface

type QueryOptimizer

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

QueryOptimizer provides query optimization capabilities

func NewOptimizer

func NewOptimizer(opts *OptimizationOptions) *QueryOptimizer

NewOptimizer creates a new query optimizer

func (*QueryOptimizer) ClearCache

func (o *QueryOptimizer) ClearCache()

ClearCache clears the query plan cache

func (*QueryOptimizer) GetQueryPlan

func (o *QueryOptimizer) GetQueryPlan(q *Query) (*QueryPlan, bool)

GetQueryPlan returns the cached query plan if available

func (*QueryOptimizer) GetStatistics

func (o *QueryOptimizer) GetStatistics(q *Query) (*QueryStatistics, bool)

GetStatistics returns query execution statistics

func (*QueryOptimizer) OptimizeQuery

func (o *QueryOptimizer) OptimizeQuery(q *Query) (*QueryPlan, error)

OptimizeQuery analyzes a query and returns an optimized execution plan

func (*QueryOptimizer) RecordExecution

func (o *QueryOptimizer) RecordExecution(q *Query, result *QueryExecutionResult)

RecordExecution records the execution statistics for adaptive optimization

type QueryPlan

type QueryPlan struct {
	ID                string
	Operation         string   // Query, Scan, BatchGet
	IndexName         string   // Which index to use
	Projections       []string // Fields to project
	EstimatedCost     *CostEstimate
	OptimizationHints []string // Human-readable optimization suggestions
	ParallelSegments  int      // For parallel scans
	CachedAt          time.Time
	Statistics        *QueryStatistics
}

QueryPlan represents an optimized query execution plan

type QueryResult

type QueryResult struct {
	Items            []map[string]types.AttributeValue
	Count            int64
	ScannedCount     int64
	LastEvaluatedKey map[string]types.AttributeValue
}

QueryResult represents the result of a query operation

type QueryStatistics

type QueryStatistics struct {
	ExecutionCount    int64
	ErrorCount        int64
	TotalDuration     time.Duration
	AverageDuration   time.Duration
	MinDuration       time.Duration
	MaxDuration       time.Duration
	TotalItemsRead    int64
	TotalItemsScanned int64
	LastExecuted      time.Time
	ErrorRate         float64
}

QueryStatistics tracks runtime statistics for queries

type RawFilter

type RawFilter struct {
	Expression string
	Params     []core.Param
}

RawFilter represents a raw filter with parameters

type RetryPolicy

type RetryPolicy struct {
	MaxRetries    int
	InitialDelay  time.Duration
	MaxDelay      time.Duration
	BackoffFactor float64
}

RetryPolicy defines retry behavior for batch operations

type ScanResult

type ScanResult struct {
	Items            []map[string]types.AttributeValue
	Count            int64
	ScannedCount     int64
	LastEvaluatedKey map[string]types.AttributeValue
}

ScanResult represents the result of a scan operation

type UpdateBuilder

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

UpdateBuilder provides a fluent API for building complex update expressions

func (*UpdateBuilder) Add

func (ub *UpdateBuilder) Add(field string, value any) core.UpdateBuilder

Add increments a numeric field (atomic counter)

func (*UpdateBuilder) AppendToList

func (ub *UpdateBuilder) AppendToList(field string, values any) core.UpdateBuilder

AppendToList appends values to the end of a list

func (*UpdateBuilder) Condition

func (ub *UpdateBuilder) Condition(field string, operator string, value any) core.UpdateBuilder

Condition adds a condition that must be met for the update to succeed

func (*UpdateBuilder) ConditionExists

func (ub *UpdateBuilder) ConditionExists(field string) core.UpdateBuilder

ConditionExists adds a condition that the field must exist

func (*UpdateBuilder) ConditionNotExists

func (ub *UpdateBuilder) ConditionNotExists(field string) core.UpdateBuilder

ConditionNotExists adds a condition that the field must not exist

func (*UpdateBuilder) ConditionVersion

func (ub *UpdateBuilder) ConditionVersion(currentVersion int64) core.UpdateBuilder

ConditionVersion adds optimistic locking based on version field

func (*UpdateBuilder) Decrement

func (ub *UpdateBuilder) Decrement(field string) core.UpdateBuilder

Decrement is an alias for Add with value -1

func (*UpdateBuilder) Delete

func (ub *UpdateBuilder) Delete(field string, value any) core.UpdateBuilder

Delete removes elements from a set

func (*UpdateBuilder) Execute

func (ub *UpdateBuilder) Execute() error

Execute performs the update operation

func (*UpdateBuilder) ExecuteWithResult

func (ub *UpdateBuilder) ExecuteWithResult(result any) error

ExecuteWithResult performs the update and returns the result

func (*UpdateBuilder) Increment

func (ub *UpdateBuilder) Increment(field string) core.UpdateBuilder

Increment is an alias for Add with value 1

func (*UpdateBuilder) OrCondition added in v1.0.6

func (ub *UpdateBuilder) OrCondition(field string, operator string, value any) core.UpdateBuilder

OrCondition adds a condition with OR logic

func (*UpdateBuilder) PrependToList

func (ub *UpdateBuilder) PrependToList(field string, values any) core.UpdateBuilder

PrependToList prepends values to the beginning of a list

func (*UpdateBuilder) Remove

func (ub *UpdateBuilder) Remove(field string) core.UpdateBuilder

Remove removes an attribute from the item

func (*UpdateBuilder) RemoveFromListAt

func (ub *UpdateBuilder) RemoveFromListAt(field string, index int) core.UpdateBuilder

RemoveFromListAt removes an element from a list at a specific index

func (*UpdateBuilder) ReturnValues

func (ub *UpdateBuilder) ReturnValues(option string) core.UpdateBuilder

ReturnValues sets what values to return after the update

func (*UpdateBuilder) Set

func (ub *UpdateBuilder) Set(field string, value any) core.UpdateBuilder

Set adds a SET expression to update a field

func (*UpdateBuilder) SetIfNotExists

func (ub *UpdateBuilder) SetIfNotExists(field string, value any, defaultValue any) core.UpdateBuilder

SetIfNotExists sets a field only if it doesn't exist

func (*UpdateBuilder) SetListElement

func (ub *UpdateBuilder) SetListElement(field string, index int, value any) core.UpdateBuilder

SetListElement sets a specific element in a list

type UpdateItemExecutor

type UpdateItemExecutor interface {
	QueryExecutor
	ExecuteUpdateItem(input *core.CompiledQuery, key map[string]types.AttributeValue) error
}

UpdateItemExecutor extends QueryExecutor with UpdateItem support

type UpdateItemWithResultExecutor

type UpdateItemWithResultExecutor interface {
	UpdateItemExecutor
	ExecuteUpdateItemWithResult(input *core.CompiledQuery, key map[string]types.AttributeValue) (*core.UpdateResult, error)
}

UpdateItemWithResultExecutor extends UpdateItemExecutor with result support

Jump to

Keyboard shortcuts

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