Documentation ¶
Index ¶
- Variables
- func Int(num int) *dynamodb.AttributeValue
- func IntList(arr ...int) *dynamodb.AttributeValue
- func PKSKExtractor(attrs map[string]*dynamodb.AttributeValue) map[string]*dynamodb.AttributeValue
- func String(str string) *dynamodb.AttributeValue
- func StringList(arr ...string) *dynamodb.AttributeValue
- func StringSet(arr ...string) *dynamodb.AttributeValue
- type Builder
- func (s *Builder) Builder() *Builder
- func (s *Builder) Client(client *Client) *Builder
- func (s *Builder) Condition(query string, vals ...interface{}) *Builder
- func (s *Builder) ConsistentRead(consistent bool) *Builder
- func (s *Builder) DeleteItem(ctx context.Context) (*dynamodb.DeleteItemOutput, error)
- func (s *Builder) GetItem(ctx context.Context) (*dynamodb.GetItemOutput, error)
- func (s *Builder) IN(column string, vals ...interface{}) *Builder
- func (s *Builder) INSlice(column string, val interface{}) *Builder
- func (s *Builder) Index(index string) *Builder
- func (s *Builder) Key(keyName string, value interface{}, additionalKVs ...interface{}) *Builder
- func (s *Builder) Limit(limit int) *Builder
- func (s *Builder) OrCondition(query string, vals ...interface{}) *Builder
- func (s *Builder) OrIN(column string, vals ...interface{}) *Builder
- func (s *Builder) OrINSlice(column string, val interface{}) *Builder
- func (s *Builder) OrWhere(query string, vals ...interface{}) *Builder
- func (s *Builder) ParallelScanIterate(ctx context.Context, workers int, fn func(output *dynamodb.ScanOutput) error, ...) error
- func (s *Builder) PutItem(ctx context.Context, data interface{}) (*dynamodb.PutItemOutput, error)
- func (s *Builder) QueryAll(ctx context.Context) ([]map[string]*dynamodb.AttributeValue, error)
- func (s *Builder) QueryDelete(ctx context.Context, keyFn KeyExtractor) error
- func (s *Builder) QueryIterate(ctx context.Context, fn func(output *dynamodb.QueryOutput) error) error
- func (s *Builder) QuerySingle(ctx context.Context) (map[string]*dynamodb.AttributeValue, error)
- func (s *Builder) Result(val interface{}) *Builder
- func (s *Builder) ScanDelete(ctx context.Context, keyFn KeyExtractor) error
- func (s *Builder) ScanIterate(ctx context.Context, fn func(output *dynamodb.ScanOutput) error) error
- func (s *Builder) SelectFields(fields ...string) *Builder
- func (s *Builder) Sort(ascending bool) *Builder
- func (s *Builder) Table(tbl string) *Builder
- func (s *Builder) ToDelete() (dynamodb.DeleteItemInput, error)
- func (s *Builder) ToGet() (dynamodb.GetItemInput, error)
- func (s *Builder) ToPut(item interface{}) (dynamodb.PutItemInput, error)
- func (s *Builder) ToQuery() (dynamodb.QueryInput, error)
- func (s *Builder) ToScan() (dynamodb.ScanInput, error)
- func (s *Builder) ToUpdate() (dynamodb.UpdateItemInput, error)
- func (s *Builder) Update(query string, vals ...interface{}) *Builder
- func (s *Builder) UpdateItem(ctx context.Context) (*dynamodb.UpdateItemOutput, error)
- func (s *Builder) Where(query string, vals ...interface{}) *Builder
- func (s *Builder) WhereKey(query string, vals ...interface{}) *Builder
- type Client
- func (c *Client) BatchGetIterator(ctx context.Context, input *dynamodb.BatchGetItemInput, ...) error
- func (c *Client) BatchPut(ctx context.Context, tableName string, items ...interface{}) (int, error)
- func (c *Client) BatchWriter(ctx context.Context, tableName string, requests ...*dynamodb.WriteRequest) (int, error)
- func (c *Client) Builder() *Builder
- func (c *Client) ChunkWriteRequests(requests []*dynamodb.WriteRequest) [][]*dynamodb.WriteRequest
- func (c *Client) CopyTable(parentCtx context.Context, dst string, src string, workers int, ...) error
- func (c *Client) ExtractFields(data map[string]*dynamodb.AttributeValue, fields ...string) map[string]*dynamodb.AttributeValue
- func (c *Client) ParallelScanIterator(ctx context.Context, input *dynamodb.ScanInput, workers int, ...) error
- func (c *Client) QueryDeleter(ctx context.Context, table string, input *dynamodb.QueryInput, ...) error
- func (c *Client) QueryIterator(ctx context.Context, input *dynamodb.QueryInput, ...) error
- func (c *Client) ScanCount(ctx context.Context, input *dynamodb.ScanInput) (int64, error)
- func (c *Client) ScanDeleter(ctx context.Context, table string, input *dynamodb.ScanInput, ...) error
- func (c *Client) ScanIterator(ctx context.Context, input *dynamodb.ScanInput, ...) error
- func (c *Client) ToBatchGetItemInput(tableName string, req []map[string]*dynamodb.AttributeValue) *dynamodb.BatchGetItemInput
- type Iterator
- type IteratorClient
- type KeyExtractor
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClientNotSet occurs if you try to make a client call from a builder without setting the client ErrClientNotSet = errors.New("client not set") // ErrBadKeyType occurs if you try to provide a non string key name ErrBadKeyType = errors.New("strings are the only type of keys supported") // ErrKeyRequired occurs if key is required for the given operation ErrKeyRequired = errors.New("key not set") // ErrBadKeyParams occurs if k/v params don't line up ErrBadKeyParams = errors.New("expected an even amount of additionalKVs parameters") // ErrUnsupportedType occurs if you are trying to add an unsupported type as an input for a query ErrUnsupportedType = errors.New("unsupported type") // ErrQueryMisMatch occurs if the number of ? don't line up with the given inputs for a query ErrQueryMisMatch = errors.New("inputs don't match query") // ErrNotSlice occurs if a non slice type is provided as a value for any of the IN builder query functions ErrNotSlice = errors.New("provided value is not a slice") // ErrNotPointer occurs if a non pointer type is provided to the Result method of the builder type ErrNotPointer = errors.New("provided result type is not a slice") )
Functions ¶
func IntList ¶
func IntList(arr ...int) *dynamodb.AttributeValue
IntList converts an array of integers to an integer list type
func PKSKExtractor ¶
func PKSKExtractor(attrs map[string]*dynamodb.AttributeValue) map[string]*dynamodb.AttributeValue
PKSKExtractor extracts the fields PK and SK
func String ¶
func String(str string) *dynamodb.AttributeValue
String converts a string to a string type
func StringList ¶
func StringList(arr ...string) *dynamodb.AttributeValue
StringList converts an array of strings to a string list type
func StringSet ¶
func StringSet(arr ...string) *dynamodb.AttributeValue
StringSet converts an array of strings to a string set type
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder allows you to build dynamo queries in a more convenient fashion
func (*Builder) Builder ¶ added in v1.1.1
Builder returns a new builder instance. If client or table was set it will also be set on new instance
func (*Builder) Client ¶
Client sets client that will be used for client operations based on built object
func (*Builder) Condition ¶
Condition allows you do make a condition expression. e.g Condition("'MyKey' = ?", "yourKey") note: calling this multiple times combines conditions with an AND
func (*Builder) ConsistentRead ¶
ConsistentRead sets the consistent read flag
func (*Builder) DeleteItem ¶
DeleteItem deletes a single item utilizing data set via Table, Keys and Condition method calls
func (*Builder) IN ¶
IN lets you build an IN filter expression e.g IN(`COL_NAME_HERE`, 1,2,3,4,5) note: if you have an existing filter expression this will be prefixed with an AND
func (*Builder) INSlice ¶
INSlice lets you build an IN filter expression from a slice e.g INSlice(`COL_NAME_HERE`, []int{1,2,3,4,5}) note: if you have an existing filter expression this will be prefixed with an AND
func (*Builder) Key ¶
Key allows you to set the key for a given item e.g Key("PK", "hello", "SK", "there")
func (*Builder) OrCondition ¶
OrCondition allows you do make an OR if you have multiple conditions e.g Condition("'MyKey' = ?", "yourKey") note: calling this multiple times combines conditions with an OR
func (*Builder) OrIN ¶
OrIN lets you build an IN filter expression e.g IN(`COL_NAME_HERE`, 1,2,3,4,5) note: if you have an existing filter expression this will be prefixed with an OR
func (*Builder) OrINSlice ¶
OrINSlice lets you build an IN filter expression from a slice e.g INSlice(`COL_NAME_HERE`, []int{1,2,3,4,5}) note: if you have an existing filter expression this will be prefixed with an OR
func (*Builder) OrWhere ¶
OrWhere is equivalent to a filter expression with an OR e.g Where("'Hey' = ? AND 'Test'.'Nested'" = ?, "yo", true).OrWhere("'Foo' = ?", "bar")
func (*Builder) ParallelScanIterate ¶
func (s *Builder) ParallelScanIterate(ctx context.Context, workers int, fn func(output *dynamodb.ScanOutput) error, unsafe bool) error
ParallelScanIterate allows you to do a parallel scan in dynamo based on the built object. the fn parameter will be called as often as needed to retrieve all results
func (*Builder) PutItem ¶ added in v1.1.0
PutItem inserts the provided data and marshal maps it using the aws sdk
func (*Builder) QueryDelete ¶
func (s *Builder) QueryDelete(ctx context.Context, keyFn KeyExtractor) error
QueryDelete deletes all records matching the query. note: you must provide a function that will select the relevant Key fields needed for deletion
func (*Builder) QueryIterate ¶
func (s *Builder) QueryIterate(ctx context.Context, fn func(output *dynamodb.QueryOutput) error) error
QueryIterate allows you to query dynamo based on the built object. the fn parameter will be called as often as needed to retrieve all results
func (*Builder) QuerySingle ¶
QuerySingle returns a single result matching the built query
func (*Builder) Result ¶
Result decodes the final result into the provided variable. Provided variable must be a pointer
func (*Builder) ScanDelete ¶
func (s *Builder) ScanDelete(ctx context.Context, keyFn KeyExtractor) error
ScanDelete deletes all records matching the scan. note: you must provide a function that will select the relevant Key fields needed for deletion
func (*Builder) ScanIterate ¶
func (s *Builder) ScanIterate(ctx context.Context, fn func(output *dynamodb.ScanOutput) error) error
ScanIterate allows you to query dynamo based on the built object. the fn parameter will be called as often as needed to retrieve all results
func (*Builder) SelectFields ¶
SelectFields allows you to select which fields to pull back from dynamo
func (*Builder) ToDelete ¶
func (s *Builder) ToDelete() (dynamodb.DeleteItemInput, error)
ToDelete produces a dynamodb.DeleteItemInput value based on configured builder
func (*Builder) ToGet ¶
func (s *Builder) ToGet() (dynamodb.GetItemInput, error)
ToGet produces a dynamodb.GetItemInput value based on configured builder
func (*Builder) ToPut ¶ added in v1.1.0
func (s *Builder) ToPut(item interface{}) (dynamodb.PutItemInput, error)
ToPut produces a dynamodb.PutItemInput value based on configured builder
func (*Builder) ToQuery ¶
func (s *Builder) ToQuery() (dynamodb.QueryInput, error)
ToQuery produces a dynamodb.QueryInput value based on configured builder
func (*Builder) ToUpdate ¶
func (s *Builder) ToUpdate() (dynamodb.UpdateItemInput, error)
ToUpdate produces a dynamodb.UpdateItemInput value based on configured builder
func (*Builder) Update ¶
Update is equivalent to an update expression e.g Update("SET 'Hey' = ?, 'Test'.'Nested'" = ?, "yo", true)
func (*Builder) UpdateItem ¶
UpdateItem builds and runs an update query
type Client ¶
Client is a wrapper around the dynamodb SDK that provides useful behavior such as iteration, processing unprocessed items and more
func (*Client) BatchGetIterator ¶
func (c *Client) BatchGetIterator(ctx context.Context, input *dynamodb.BatchGetItemInput, fn func(output *dynamodb.GetItemOutput) error) error
BatchGetIterator retrieves all items from the batch get input
func (*Client) BatchPut ¶
BatchPut allows you to put a batch of items to a table items will me converted to a marshal map
func (*Client) BatchWriter ¶
func (c *Client) BatchWriter(ctx context.Context, tableName string, requests ...*dynamodb.WriteRequest) (int, error)
BatchWriter batch writes an array of write requests to a table
func (*Client) ChunkWriteRequests ¶
func (c *Client) ChunkWriteRequests(requests []*dynamodb.WriteRequest) [][]*dynamodb.WriteRequest
ChunkWriteRequests chunks write requests into batches of 25 (the current maximum size in AWS)
func (*Client) CopyTable ¶
func (c *Client) CopyTable(parentCtx context.Context, dst string, src string, workers int, onError func(err error, cancelFunc context.CancelFunc)) error
CopyTable copies all data in source to the existing destination table using
func (*Client) ExtractFields ¶
func (c *Client) ExtractFields(data map[string]*dynamodb.AttributeValue, fields ...string) map[string]*dynamodb.AttributeValue
ExtractFields extracts fields from a map of dynamo attribute values
func (*Client) ParallelScanIterator ¶
func (c *Client) ParallelScanIterator(ctx context.Context, input *dynamodb.ScanInput, workers int, fn func(output *dynamodb.ScanOutput) error, noLock bool) error
ParallelScanIterator is a thread safe method that performs a parallel scan on dynamodb utilizing the configured amount of workers
func (*Client) QueryDeleter ¶
func (c *Client) QueryDeleter(ctx context.Context, table string, input *dynamodb.QueryInput, keyFn KeyExtractor) error
QueryDeleter deletes all records that match the query
func (*Client) QueryIterator ¶
func (c *Client) QueryIterator(ctx context.Context, input *dynamodb.QueryInput, fn func(output *dynamodb.QueryOutput) error) error
QueryIterator iterates all results of a query
func (*Client) ScanDeleter ¶
func (c *Client) ScanDeleter(ctx context.Context, table string, input *dynamodb.ScanInput, keyFn KeyExtractor) error
ScanDeleter deletes all records that match the scan query
func (*Client) ScanIterator ¶
func (c *Client) ScanIterator(ctx context.Context, input *dynamodb.ScanInput, fn func(output *dynamodb.ScanOutput) error) error
ScanIterator iterates all results of a scan
func (*Client) ToBatchGetItemInput ¶
func (c *Client) ToBatchGetItemInput(tableName string, req []map[string]*dynamodb.AttributeValue) *dynamodb.BatchGetItemInput
ToBatchGetItemInput converts an array of mapped dynamo attributes to a batch get item input
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator provides result iteration behavior
func NewIteratorFromQuery ¶
func NewIteratorFromQuery(ctx context.Context, cli IteratorClient, input *dynamodb.QueryInput) *Iterator
NewIteratorFromQuery creates a new iterator from a query
func NewIteratorFromScan ¶
func NewIteratorFromScan(ctx context.Context, cli IteratorClient, input *dynamodb.ScanInput) *Iterator
NewIteratorFromScan creates a new iterator from a scan
func (*Iterator) QueryValue ¶
func (i *Iterator) QueryValue() *dynamodb.QueryOutput
QueryValue returns the current query output
func (*Iterator) ScanValue ¶
func (i *Iterator) ScanValue() *dynamodb.ScanOutput
ScanValue returns the current scan output
type IteratorClient ¶
type IteratorClient interface { QueryRequest(input *dynamodb.QueryInput) (req *request.Request, output *dynamodb.QueryOutput) ScanRequest(input *dynamodb.ScanInput) (req *request.Request, output *dynamodb.ScanOutput) }
IteratorClient is an interface for all methods utilized by iterator
type KeyExtractor ¶
type KeyExtractor func(map[string]*dynamodb.AttributeValue) map[string]*dynamodb.AttributeValue
KeyExtractor is a type primarily used to get necessary fields needed to delete a record
func FieldsExtractor ¶
func FieldsExtractor(fields ...string) KeyExtractor
FieldsExtractor extracts the provided fields