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 ¶
- func Between(lo, hi any) []any
- func EncodeCursor(lastKey map[string]types.AttributeValue, indexName string, ...) (string, error)
- func FirstOrNil(q core.Query, dest any) (bool, error)
- func NewUpdateBuilder(q *Query) core.UpdateBuilder
- func UnmarshalItem(item map[string]types.AttributeValue, dest any) error
- func UnmarshalItems(items []map[string]types.AttributeValue, dest any) error
- type AggregateResult
- type AttributeValueConverter
- type BatchExecutor
- type BatchGetResult
- type BatchResult
- type BatchUpdateOptions
- type BatchWriteItemExecutor
- type CompiledBatchGet
- type CompiledBatchWrite
- type CompiledScan
- type Condition
- type CostEstimate
- type Cursor
- type DeleteItemExecutor
- type Filter
- type GetItemExecutor
- type GroupByQuery
- func (g *GroupByQuery) Avg(field, alias string) *GroupByQuery
- func (g *GroupByQuery) Count(alias string) *GroupByQuery
- func (g *GroupByQuery) Execute() ([]*GroupedResult, error)
- func (g *GroupByQuery) Having(aggregate, operator string, value any) *GroupByQuery
- func (g *GroupByQuery) Max(field, alias string) *GroupByQuery
- func (g *GroupByQuery) Min(field, alias string) *GroupByQuery
- func (g *GroupByQuery) Sum(field, alias string) *GroupByQuery
- type GroupedResult
- type Operator
- type OptimizationOptions
- type OptimizedQuery
- type OrderBy
- type PaginatedQueryExecutor
- type PaginatedResult
- type PutItemExecutor
- type Query
- func (q *Query) Aggregate(fields ...string) (*AggregateResult, error)
- func (q *Query) All(dest any) error
- func (q *Query) AllPaginated(dest any) (*core.PaginatedResult, error)
- func (q *Query) Average(field string) (float64, error)
- func (q *Query) BatchCreate(items any) error
- func (q *Query) BatchCreateWithResult(items any) (*BatchResult, error)
- func (q *Query) BatchDelete(keys []any) error
- func (q *Query) BatchDeleteWithOptions(keys []any, opts *BatchUpdateOptions) error
- func (q *Query) BatchGet(keys []any, dest any) error
- func (q *Query) BatchGetBuilder() core.BatchGetBuilder
- func (q *Query) BatchGetWithOptions(keys []any, dest any, opts *core.BatchGetOptions) error
- func (q *Query) BatchUpdate(items any, fields ...string) error
- func (q *Query) BatchUpdateWithOptions(items []any, fields []string, options ...any) error
- func (q *Query) BatchWrite(putItems []any, deleteKeys []any) error
- func (q *Query) BatchWriteWithOptions(putItems []any, deleteKeys []any, opts *BatchUpdateOptions) error
- func (q *Query) Compile() (*core.CompiledQuery, error)
- func (q *Query) ConsistentRead() core.Query
- func (q *Query) Count() (int64, error)
- func (q *Query) CountDistinct(field string) (int64, error)
- func (q *Query) Create() error
- func (q *Query) CreateOrUpdate() error
- func (q *Query) Cursor(cursor string) core.Query
- func (q *Query) Delete() error
- func (q *Query) Filter(field string, op string, value any) core.Query
- func (q *Query) FilterGroup(fn func(core.Query)) core.Query
- func (q *Query) First(dest any) error
- func (q *Query) FirstOrNil(dest any) (bool, error)
- func (q *Query) GroupBy(field string) *GroupByQuery
- func (q *Query) Having(condition string, value any) core.Query
- func (q *Query) IfExists() core.Query
- func (q *Query) IfNotExists() core.Query
- func (q *Query) Index(name string) core.Query
- func (q *Query) Limit(n int) core.Query
- func (q *Query) Max(field string) (any, error)
- func (q *Query) Min(field string) (any, error)
- func (q *Query) Offset(offset int) core.Query
- func (q *Query) OrFilter(field string, op string, value any) core.Query
- func (q *Query) OrFilterGroup(fn func(core.Query)) core.Query
- func (q *Query) OrderBy(field string, order string) core.Query
- func (q *Query) ParallelScan(segment int32, totalSegments int32) core.Query
- func (q *Query) QueryTimeout(timeout time.Duration) core.Query
- func (q *Query) Scan(dest any) error
- func (q *Query) ScanAllSegments(dest any, totalSegments int32) error
- func (q *Query) Select(fields ...string) core.Query
- func (q *Query) SetCursor(cursor string) error
- func (q *Query) Sum(field string) (float64, error)
- func (q *Query) Update(fields ...string) error
- func (q *Query) UpdateBuilder() core.UpdateBuilder
- func (q *Query) Where(field string, op string, value any) core.Query
- func (q *Query) WithCancellation() (core.Query, *QueryCanceler)
- func (q *Query) WithCondition(field, operator string, value any) core.Query
- func (q *Query) WithConditionExpression(exprStr string, values map[string]any) core.Query
- func (q *Query) WithContext(ctx context.Context) core.Query
- func (q *Query) WithConverter(converter AttributeValueConverter) *Query
- func (q *Query) WithMarshaler(marshaler marshal.MarshalerInterface) *Query
- func (q *Query) WithOptimizer(optimizer *QueryOptimizer) (*OptimizedQuery, error)
- func (q *Query) WithRetry(maxRetries int, initialDelay time.Duration) core.Query
- type QueryCanceler
- type QueryExecutionResult
- type QueryExecutor
- type QueryOptimizer
- func (o *QueryOptimizer) ClearCache()
- func (o *QueryOptimizer) GetQueryPlan(q *Query) (*QueryPlan, bool)
- func (o *QueryOptimizer) GetStatistics(q *Query) (*QueryStatistics, bool)
- func (o *QueryOptimizer) OptimizeQuery(q *Query) (*QueryPlan, error)
- func (o *QueryOptimizer) RecordExecution(q *Query, result *QueryExecutionResult)
- type QueryPlan
- type QueryResult
- type QueryStatistics
- type RawFilter
- type RetryConfig
- type RetryPolicy
- type ScanResult
- type UpdateBuilder
- func (ub *UpdateBuilder) Add(field string, value any) core.UpdateBuilder
- func (ub *UpdateBuilder) AppendToList(field string, values any) core.UpdateBuilder
- func (ub *UpdateBuilder) Condition(field string, operator string, value any) core.UpdateBuilder
- func (ub *UpdateBuilder) ConditionExists(field string) core.UpdateBuilder
- func (ub *UpdateBuilder) ConditionNotExists(field string) core.UpdateBuilder
- func (ub *UpdateBuilder) ConditionVersion(currentVersion int64) core.UpdateBuilder
- func (ub *UpdateBuilder) Decrement(field string) core.UpdateBuilder
- func (ub *UpdateBuilder) Delete(field string, value any) core.UpdateBuilder
- func (ub *UpdateBuilder) Execute() error
- func (ub *UpdateBuilder) ExecuteWithResult(result any) error
- func (ub *UpdateBuilder) Increment(field string) core.UpdateBuilder
- func (ub *UpdateBuilder) OrCondition(field string, operator string, value any) core.UpdateBuilder
- func (ub *UpdateBuilder) PrependToList(field string, values any) core.UpdateBuilder
- func (ub *UpdateBuilder) Remove(field string) core.UpdateBuilder
- func (ub *UpdateBuilder) RemoveFromListAt(field string, index int) core.UpdateBuilder
- func (ub *UpdateBuilder) ReturnValues(option string) core.UpdateBuilder
- func (ub *UpdateBuilder) Set(field string, value any) core.UpdateBuilder
- func (ub *UpdateBuilder) SetIfNotExists(field string, value any, defaultValue any) core.UpdateBuilder
- func (ub *UpdateBuilder) SetListElement(field string, index int, value any) core.UpdateBuilder
- type UpdateItemExecutor
- type UpdateItemWithResultExecutor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Between ¶
Between returns the two-value operand shape expected by DynamoDB BETWEEN expressions.
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
func FirstOrNil ¶
FirstOrNil executes any TableTheory query and reports whether an item was found. Queries that provide their own FirstOrNil implementation use it; otherwise this helper falls back to First while only suppressing ErrItemNotFound.
func NewUpdateBuilder ¶
func NewUpdateBuilder(q *Query) core.UpdateBuilder
NewUpdateBuilder creates a new UpdateBuilder with the given query
func UnmarshalItem ¶
func UnmarshalItem(item map[string]types.AttributeValue, dest any) error
UnmarshalItem unmarshals a single DynamoDB item into a Go struct. This function respects both "dynamodb" and "theorydb" struct tags.
func UnmarshalItems ¶
func UnmarshalItems(items []map[string]types.AttributeValue, dest any) error
UnmarshalItems unmarshals DynamoDB items into the destination. This function is exported for use with DynamoDB streams and other external data sources.
Types ¶
type AggregateResult ¶
AggregateResult holds the result of an aggregate operation
type AttributeValueConverter ¶
type AttributeValueConverter interface {
HasCustomConverter(typ reflect.Type) bool
ToAttributeValue(value any) (types.AttributeValue, error)
FromAttributeValue(av types.AttributeValue, target any) error
ConvertToSet(slice any, isSet bool) (types.AttributeValue, error)
}
AttributeValueConverter allows TableTheory callers to inject custom converter behavior. It intentionally mirrors the relevant subset of `pkg/types.Converter` without requiring callers to depend on that concrete type.
type BatchExecutor ¶
type BatchExecutor interface {
QueryExecutor
ExecuteBatchGet(input *CompiledBatchGet, opts *core.BatchGetOptions) ([]map[string]types.AttributeValue, 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 ¶
BatchResult represents the result of a batch operation.
Errors holds one entry per failed item, Failed counts those items, and Succeeded counts the items that were written. UnprocessedKeys is retained for API compatibility and is not populated; per-item failures are reported through Errors and Failed instead.
type BatchUpdateOptions ¶
type BatchUpdateOptions struct {
ProgressCallback func(processed, total int)
ErrorHandler func(item any, err error) error
RetryPolicy *RetryPolicy
MaxBatchSize int
MaxConcurrency int
Parallel bool
}
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 {
ExpressionAttributeNames map[string]string
TableName string
ProjectionExpression string
Keys []map[string]types.AttributeValue
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 {
ExpressionAttributeNames map[string]string
ExpressionAttributeValues map[string]types.AttributeValue
Limit *int32
ExclusiveStartKey map[string]types.AttributeValue
Segment *int32
TotalSegments *int32
TableName string
FilterExpression string
ProjectionExpression string
ConsistentRead bool
}
CompiledScan represents a compiled scan operation
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 ¶
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 GetItemExecutor ¶
type GetItemExecutor interface {
QueryExecutor
ExecuteGetItem(input *core.CompiledQuery, key map[string]types.AttributeValue, dest any) error
}
GetItemExecutor extends QueryExecutor with GetItem support.
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
Aggregates map[string]*AggregateResult
Items []any
Count int64
}
GroupBy groups results by a field and performs aggregate operations
type Operator ¶
type Operator string
Operator identifies a DynamoDB condition/filter operator accepted by TableTheory query builders.
const ( // OpEqual compares equality. OpEqual Operator = "=" // OpNotEqual compares inequality. OpNotEqual Operator = "<>" // OpLessThan compares values lower than the operand. OpLessThan Operator = "<" // OpLessThanOrEqual compares values lower than or equal to the operand. OpLessThanOrEqual Operator = "<=" // OpGreaterThan compares values greater than the operand. OpGreaterThan Operator = ">" // OpGreaterThanOrEqual compares values greater than or equal to the operand. OpGreaterThanOrEqual Operator = ">=" // OpBetween compares a value against an inclusive lower/upper bound pair. OpBetween Operator = "BETWEEN" // OpIn compares membership in a bounded value list. OpIn Operator = "IN" // OpBeginsWith matches string/binary sort-key or filter prefixes. OpBeginsWith Operator = "BEGINS_WITH" // OpContains matches collection or substring containment. OpContains Operator = "CONTAINS" // OpExists checks that an attribute exists. OpExists Operator = "ATTRIBUTE_EXISTS" // OpNotExists checks that an attribute does not exist. OpNotExists Operator = "ATTRIBUTE_NOT_EXISTS" )
const ( // OpEQ is an alias for OpEqual. OpEQ Operator = "EQ" // OpNE is an alias for OpNotEqual. OpNE Operator = "NE" // OpLT is an alias for OpLessThan. OpLT Operator = "LT" // OpLE is an alias for OpLessThanOrEqual. OpLE Operator = "LE" // OpGT is an alias for OpGreaterThan. OpGT Operator = "GT" // OpGE is an alias for OpGreaterThanOrEqual. OpGE Operator = "GE" )
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 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 NewWithConditions ¶
func NewWithConditions(model any, metadata core.ModelMetadata, executor QueryExecutor, conditions []Condition, ctx context.Context) *Query
NewWithConditions creates a new Query instance with all necessary fields
func (*Query) Aggregate ¶
func (q *Query) Aggregate(fields ...string) (*AggregateResult, error)
Aggregate performs multiple aggregate operations in a single pass
func (*Query) AllPaginated ¶
func (q *Query) AllPaginated(dest any) (*core.PaginatedResult, error)
AllPaginated executes the query and returns paginated results
func (*Query) BatchCreate ¶
BatchCreate creates multiple items.
func (*Query) BatchCreateWithResult ¶
func (q *Query) BatchCreateWithResult(items any) (*BatchResult, error)
BatchCreateWithResult creates multiple items and returns detailed per-item results.
The operation continues past item-level failures: items that fail to marshal and items in chunks whose batch write fails are counted in Failed with their errors collected in Errors, while successfully written items are counted in Succeeded. A non-nil error is returned only for environment-level failures (invalid input, unsupported executor, or write-once/protected-field guard violations); item-level failures are reported through the result instead.
func (*Query) BatchDelete ¶
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 ¶
BatchGet retrieves multiple items by their primary keys using default options.
func (*Query) BatchGetBuilder ¶
func (q *Query) BatchGetBuilder() core.BatchGetBuilder
BatchGetBuilder returns a fluent builder for composing advanced BatchGet operations.
func (*Query) BatchGetWithOptions ¶
BatchGetWithOptions retrieves items with fine-grained control over chunking, retries, and callbacks.
func (*Query) BatchUpdate ¶
BatchUpdate performs batch update operations
func (*Query) BatchUpdateWithOptions ¶
BatchUpdateWithOptions implements core.Query interface with the expected signature
func (*Query) BatchWrite ¶
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) ConsistentRead ¶
ConsistentRead enables strongly consistent reads for Query operations
func (*Query) CountDistinct ¶
CountDistinct counts unique values for a field
func (*Query) Create ¶
Create creates a new item and fails if its partition key already exists. Use CreateOrUpdate when intentional overwrite/upsert semantics are required.
func (*Query) CreateOrUpdate ¶
CreateOrUpdate creates a new item or updates an existing one (upsert)
func (*Query) FilterGroup ¶
FilterGroup adds a grouped AND filter condition
func (*Query) FirstOrNil ¶
FirstOrNil executes the query and reports whether an item was found. ErrItemNotFound is translated into (false, nil); all other errors are returned unchanged.
func (*Query) GroupBy ¶
func (q *Query) GroupBy(field string) *GroupByQuery
GroupBy groups items by a field
func (*Query) Having ¶
Having is deprecated - use GroupBy().Having() instead for proper aggregate filtering This method is kept for backward compatibility but does nothing
func (*Query) IfNotExists ¶
IfNotExists ensures the primary key does not exist prior to write
func (*Query) OrFilterGroup ¶
OrFilterGroup adds a grouped OR filter condition
func (*Query) ParallelScan ¶
ParallelScan performs a parallel table scan with the specified segment
func (*Query) QueryTimeout ¶
QueryTimeout sets a timeout for the query execution
func (*Query) ScanAllSegments ¶
ScanAllSegments performs a parallel scan across all segments and combines results
func (*Query) UpdateBuilder ¶
func (q *Query) UpdateBuilder() core.UpdateBuilder
UpdateBuilder returns a builder for complex update operations
func (*Query) WithCancellation ¶
func (q *Query) WithCancellation() (core.Query, *QueryCanceler)
WithCancellation returns a query that can be canceled
func (*Query) WithCondition ¶
WithCondition appends an additional write condition
func (*Query) WithConditionExpression ¶
WithConditionExpression appends a raw condition expression for advanced cases
func (*Query) WithContext ¶
WithContext sets the context for the query
func (*Query) WithConverter ¶
func (q *Query) WithConverter(converter AttributeValueConverter) *Query
WithConverter configures the query to use the provided converter for expression and key/value conversion.
This is optional; when unset, the query falls back to the internal expression converter.
func (*Query) WithMarshaler ¶
func (q *Query) WithMarshaler(marshaler marshal.MarshalerInterface) *Query
WithMarshaler configures the query to use the provided marshaler for PutItem-style operations.
This is optional; when unset, the query falls back to reflection-based conversion.
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
type QueryExecutionResult ¶
type QueryExecutionResult struct {
Error error
Duration time.Duration
ItemsReturned int64
ItemsScanned int64
}
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 {
CachedAt time.Time
EstimatedCost *CostEstimate
Statistics *QueryStatistics
ID string
Operation string
IndexName string
Projections []string
OptimizationHints []string
ParallelSegments int
}
QueryPlan represents an optimized query execution plan
type QueryResult ¶
type QueryResult struct {
LastEvaluatedKey map[string]types.AttributeValue
Items []map[string]types.AttributeValue
Count int64
ScannedCount int64
}
QueryResult represents the result of a query operation
type QueryStatistics ¶
type QueryStatistics struct {
LastExecuted time.Time
ExecutionCount int64
ErrorCount int64
TotalDuration time.Duration
AverageDuration time.Duration
MinDuration time.Duration
MaxDuration time.Duration
TotalItemsRead int64
TotalItemsScanned int64
ErrorRate float64
}
QueryStatistics tracks runtime statistics for queries
type RetryConfig ¶
RetryConfig configures retry behavior
type RetryPolicy ¶
type RetryPolicy = core.RetryPolicy
RetryPolicy is an alias to core.RetryPolicy for backwards compatibility.
type ScanResult ¶
type ScanResult struct {
LastEvaluatedKey map[string]types.AttributeValue
Items []map[string]types.AttributeValue
Count int64
ScannedCount int64
}
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 ¶
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