dynamo

package module
v0.0.0-...-2877ce2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2017 License: Apache-2.0 Imports: 7 Imported by: 2

README

go-dynamo

A minimal abstraction for accessing DynamoDB on top of the official AWS SDK that makes using it a bit more expressive

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConditionInput

type ConditionInput struct {
	ConditionError error
}

ConditionInput allows working with condition expressions

func (*ConditionInput) SetConditionError

func (ci *ConditionInput) SetConditionError(err error)

SetConditionError configures the err that returns

type Delete

type Delete struct {
	ConditionInput
	ExpressionHolder
	dynamodb.DeleteItemInput
	PrimaryKey interface{}
}

Delete holds configuration for a delete

func NewDelete

func NewDelete(tname string, pk interface{}) *Delete

NewDelete prepares a query with it mandatory elements

func (*Delete) Execute

func (inp *Delete) Execute(db dynamodbiface.DynamoDBAPI) (err error)

Execute will delete an item with the background context

func (*Delete) ExecuteWithContext

func (inp *Delete) ExecuteWithContext(ctx aws.Context, db dynamodbiface.DynamoDBAPI) (err error)

ExecuteWithContext will delete an item from by its primary key

type ExpressionHolder

type ExpressionHolder struct {
	ExpAttrNames  map[string]string
	ExpAttrValues map[string]interface{}
}

ExpressionHolder makes working with expression attributes easier

func (*ExpressionHolder) AddExpressionName

func (eh *ExpressionHolder) AddExpressionName(placeholder, name string)

AddExpressionName adds an dynamo expression name

func (*ExpressionHolder) AddExpressionValue

func (eh *ExpressionHolder) AddExpressionValue(placeholder string, val interface{})

AddExpressionValue adds an dynamo expression value

type Get

type Get struct {
	ExpressionHolder
	dynamodb.GetItemInput
	ItemNilError error
	PrimaryKey   interface{}
}

Get holds configuration for getting an item

func NewGet

func NewGet(tname string, pk interface{}) *Get

NewGet prepares a query with it mandatory elements

func (*Get) Execute

func (inp *Get) Execute(db dynamodbiface.DynamoDBAPI, item interface{}) (err error)

Execute will get an item with the background context

func (*Get) ExecuteWithContext

func (inp *Get) ExecuteWithContext(ctx aws.Context, db dynamodbiface.DynamoDBAPI, item interface{}) (err error)

ExecuteWithContext will retrieve a specific item from a DynamoDB table by its primary key

func (*Get) SetItemNilError

func (inp *Get) SetItemNilError(err error)

SetItemNilError allows for configured the error (if any) when nothing is found

type PagingInput

type PagingInput struct {
	MaxPages int
}

PagingInput is used when paging can be configured

func (*PagingInput) SetMaxPages

func (pi *PagingInput) SetMaxPages(n int)

SetMaxPages limits the number of pages returned

type Put

type Put struct {
	ExpressionHolder
	dynamodb.PutItemInput
	ConditionInput
	Item interface{}
}

Put holds configuration for getting an item

func NewPut

func NewPut(tname string, item interface{}) *Put

NewPut prepares a query with it mandatory elements

func (*Put) Execute

func (inp *Put) Execute(db dynamodbiface.DynamoDBAPI) (err error)

Execute will perform the put with a background context

func (*Put) ExecuteWithContext

func (inp *Put) ExecuteWithContext(ctx aws.Context, db dynamodbiface.DynamoDBAPI) (err error)

ExecuteWithContext will put a item into a DynamoDB table

type Query

Query holds configuration for a query

func NewQuery

func NewQuery(tname, kcond string) *Query

NewQuery prepares a query with it mandatory elements

func (*Query) Execute

func (inp *Query) Execute(db dynamodbiface.DynamoDBAPI, items interface{}) (count int64, err error)

Execute will perform the query with a background context

func (*Query) ExecuteWithContext

func (inp *Query) ExecuteWithContext(ctx aws.Context, db dynamodbiface.DynamoDBAPI, items interface{}) (count int64, err error)

ExecuteWithContext will perform the query

type Scan

Scan holds configuration for a query

func NewScan

func NewScan(tname string) *Scan

NewScan prepares a query with it mandatory elements

func (*Scan) Execute

func (inp *Scan) Execute(db dynamodbiface.DynamoDBAPI, items interface{}) (count int64, err error)

Execute will scan all items (across partitions) with a background context

func (*Scan) ExecuteWithContext

func (inp *Scan) ExecuteWithContext(ctx aws.Context, db dynamodbiface.DynamoDBAPI, items interface{}) (count int64, err error)

ExecuteWithContext reads all items (across partitions) in a table or index

type Update

type Update struct {
	ConditionInput
	ExpressionHolder
	dynamodb.UpdateItemInput
	PrimaryKey interface{}
}

Update holds configuration for a delete

func NewUpdate

func NewUpdate(tname string, pk interface{}) *Update

NewUpdate prepares a query with it mandatory elements

func (*Update) Execute

func (inp *Update) Execute(db dynamodbiface.DynamoDBAPI) (err error)

Execute will update an item with the background context

func (*Update) ExecuteWithContext

func (inp *Update) ExecuteWithContext(ctx aws.Context, db dynamodbiface.DynamoDBAPI) (err error)

ExecuteWithContext updates an item in a DynamoDB table by its primary key pk with exp

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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