dynamo-browse/internal/dynamo-browse/models/queryexpr/ir.go
Leon Mika f65c5778a9
issue-50: fixed package name (#52)
Changed package name from github.com/lmika/audax to github.com/lmika/dynamo-browse
2023-04-17 08:31:03 +10:00

49 lines
1.3 KiB
Go

package queryexpr
import (
"github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression"
"github.com/lmika/dynamo-browse/internal/dynamo-browse/models"
)
// TO DELETE = operandFieldName() string
type irAtom interface {
// calcQueryForScan returns the condition builder for this atom to include in a scan
calcQueryForScan(info *models.TableInfo) (expression.ConditionBuilder, error)
}
type queryableIRAtom interface {
irAtom
// canBeExecutedAsQuery returns true if the atom is capable of being executed as a query
canBeExecutedAsQuery(qci *queryCalcInfo) bool
// calcQueryForQuery returns a key condition builder for this atom to include in a query
calcQueryForQuery() (expression.KeyConditionBuilder, error)
}
type oprIRAtom interface {
calcOperand(info *models.TableInfo) expression.OperandBuilder
}
type nameIRAtom interface {
oprIRAtom
// keyName returns the name as key if it can be a DB key. Returns "" if this name cannot be a key
keyName() string
calcName(info *models.TableInfo) expression.NameBuilder
}
type valueIRAtom interface {
oprIRAtom
exprValue() exprValue
}
func canExecuteAsQuery(ir irAtom, qci *queryCalcInfo) bool {
queryable, isQuearyable := ir.(queryableIRAtom)
if !isQuearyable {
return false
}
return queryable.canBeExecutedAsQuery(qci)
}