querybuilder

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Acc

type Acc struct {
	Key    string
	Filter string
}

type Context

type Context struct {
	HashKey          string
	SortKey          string
	NamedParams      map[string]Empty
	PositionalParams map[int]string
	FixedParams      map[string]interface{}
	Substitutions    map[string]string
	// contains filtered or unexported fields
}

Context tracks expression state as DynamoDB request is built.

func NewContext

func NewContext(table *schema.Table, index string) *Context

func (*Context) BuildPath

func (c *Context) BuildPath(path *parser.DocumentPath) string

BuildPath applies substitutions for reserved keywords in a parser.DocumentPath and marshals it into string format.

func (*Context) IsKey

func (c *Context) IsKey(field string) bool

IsKey returns true if the field is a hash key or sort key for the selected table/index.

func (*Context) NextGeneratedParam

func (c *Context) NextGeneratedParam() string

NextGeneratedParam returns the next generated parameter placeholder name. DynamoDB requires concrete values to be passed as expression values, so we simulate expression values by generating placeholders.

func (*Context) NextPositionalParam

func (c *Context) NextPositionalParam() (int, string)

NextPositionalParam returns the next generated positional placeholder name. DynamoDB does not support positional parameters so we simulate it by generating named placeholders.

type Empty

type Empty struct{}

type FilterExpression

type FilterExpression struct{}

type KeyExpression

type KeyExpression struct{}

type NamedParams

type NamedParams map[string]Empty

func (NamedParams) Clone

func (p NamedParams) Clone() NamedParams

type PreparedQuery

type PreparedQuery struct {
	Query            *dynamodb.QueryInput
	Limit            int
	Columns          []*parser.ProjectionColumn
	NamedParams      NamedParams
	PositionalParams map[int]string
	FixedParams      map[string]interface{}
}

func PrepareQuery

func PrepareQuery(ctx context.Context, tables *schema.TableLoader, query string) (*PreparedQuery, error)

func (*PreparedQuery) NewRequest

func (pq *PreparedQuery) NewRequest(args []driver.NamedValue) (*dynamodb.QueryInput, error)

Jump to

Keyboard shortcuts

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