dynamodb

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComparisonOperatorEQ = "EQ"
	ComparisonOperatorNE = "NE"
	ComparisonOperatorGT = "GT"
	ComparisonOperatorLT = "LT"
	ComparisonOperatorGE = "GE"
	ComparisonOperatorLE = "LE"
)
View Source
const (
	KeyTypeHash  = "HASH"
	KeyTypeRange = "RANGE"
)
View Source
const (
	ProjectionTypeAll      = "ALL"
	ProjectionTypeKeysOnly = "KEYS_ONLY"
)

Variables

This section is empty.

Functions

func Boolean

func Boolean(v bool) *bool

func Long

func Long(v int64) *int64

func Marshal

func Marshal(item map[string]interface{}) map[string]*SDK.AttributeValue

Convert map to DynamoDb Item data

func MarshalStringSlice

func MarshalStringSlice(item Any) []*string

Convert string slice to DynamoDb Item data

func NewAttributeDefinition

func NewAttributeDefinition(attrName, attrType string) *SDK.AttributeDefinition

Create new definition of table

func NewAttributeDefinitions

func NewAttributeDefinitions(attr ...*SDK.AttributeDefinition) []*SDK.AttributeDefinition

Convert multiple definition to single slice

func NewBoolAttribute

func NewBoolAttribute(attrName string) *SDK.AttributeDefinition

NewBoolAttribute returns a table AttributeDefinition for boolean

func NewByteAttribute

func NewByteAttribute(attrName string) *SDK.AttributeDefinition

NewByteAttribute returns a table AttributeDefinition for byte

func NewCondition

func NewCondition(value Any, operator string) SDK.Condition

Create new DynamoDB condition for Query operation

func NewExpected

func NewExpected() *SDK.ExpectedAttributeValue

Create new empty condition for put

func NewExpectedCondition

func NewExpectedCondition(value Any, operator string) *SDK.ExpectedAttributeValue

Create new condition for put

func NewGSI

func NewGSI(name string, schema []*SDK.KeySchemaElement, tp *SDK.ProvisionedThroughput, projection ...string) *SDK.GlobalSecondaryIndex

NewGSI returns initilized GlobalSecondaryIndex

func NewHashKeyElement

func NewHashKeyElement(keyName string) *SDK.KeySchemaElement

Create new single KeySchema for HashKey

func NewKeyElement

func NewKeyElement(keyName, keyType string) *SDK.KeySchemaElement

Create new single KeySchema

func NewKeySchema

func NewKeySchema(elements ...*SDK.KeySchemaElement) []*SDK.KeySchemaElement

Create new KeySchema slice

func NewLSI

func NewLSI(name string, schema []*SDK.KeySchemaElement, projection ...string) *SDK.LocalSecondaryIndex

NewLSI returns initilized LocalSecondaryIndex

func NewNumberAttribute

func NewNumberAttribute(attrName string) *SDK.AttributeDefinition

NewNumberAttribute returns a table AttributeDefinition for number

func NewProvisionedThroughput

func NewProvisionedThroughput(read, write int64) *SDK.ProvisionedThroughput

func NewRangeKeyElement

func NewRangeKeyElement(keyName string) *SDK.KeySchemaElement

Create new single KeySchema for RangeKey

func NewStringAttribute

func NewStringAttribute(attrName string) *SDK.AttributeDefinition

NewStringAttribute returns a table AttributeDefinition for string

func String

func String(v string) *string

func Unmarshal

func Unmarshal(item map[string]*SDK.AttributeValue) map[string]interface{}

Convert DynamoDB Item to map data

Types

type AmazonDynamoDB

type AmazonDynamoDB struct {
	TablePrefix string
	// contains filtered or unexported fields
}

wrapped struct for DynamoDB

func NewClient

func NewClient() *AmazonDynamoDB

Create new AmazonDynamoDB struct

func NewClientWithKeys

func NewClientWithKeys(k auth.Keys) *AmazonDynamoDB

Create new AmazonDynamoDB struct

func (*AmazonDynamoDB) CreateTable

func (d *AmazonDynamoDB) CreateTable(ct *CreateTableInput) error

Create new DynamoDB table

func (*AmazonDynamoDB) DeleteTable

func (d *AmazonDynamoDB) DeleteTable(name string) error

Delete DynamoDB table

func (*AmazonDynamoDB) DeleteTableWithPrefix

func (d *AmazonDynamoDB) DeleteTableWithPrefix(name string) error

Delete DynamoDB table

func (*AmazonDynamoDB) DescribeTable

func (d *AmazonDynamoDB) DescribeTable(name string) (*TableDescription, error)

get infomation of the table

func (*AmazonDynamoDB) DescribeTableWithPrefix

func (d *AmazonDynamoDB) DescribeTableWithPrefix(name string) (*TableDescription, error)

get infomation of the table

func (*AmazonDynamoDB) GetTable

func (d *AmazonDynamoDB) GetTable(table string) (*DynamoTable, error)

get the DynamoDB table

func (*AmazonDynamoDB) ListTables

func (d *AmazonDynamoDB) ListTables() ([]*string, error)

get the list of DynamoDB table

func (*AmazonDynamoDB) PutAll

func (d *AmazonDynamoDB) PutAll() error

execute put operation for all tables in write spool

type Any

type Any interface{}

type CreateTableInput

type CreateTableInput struct {
	Name          string
	HashKey       *SDK.KeySchemaElement
	RangeKey      *SDK.KeySchemaElement
	LSI           []*SDK.LocalSecondaryIndex
	GSI           []*SDK.GlobalSecondaryIndex
	ReadCapacity  int64
	WriteCapacity int64
	Attributes    map[string]*SDK.AttributeDefinition
}

CreateTableInput is wrapper struct for CreateTable operation

func NewCreateTableWithHashKeyN

func NewCreateTableWithHashKeyN(tableName, keyName string) *CreateTableInput

NewCreateTableWithHashKeyN returns create table request data for number hashkey

func NewCreateTableWithHashKeyS

func NewCreateTableWithHashKeyS(tableName, keyName string) *CreateTableInput

NewCreateTableWithHashKeyS returns create table request data for string hashkey

func (*CreateTableInput) AddGSIN

func (ct *CreateTableInput) AddGSIN(name, hashKey string)

func (*CreateTableInput) AddGSINN

func (ct *CreateTableInput) AddGSINN(name, hashKey, rangeKey string)

func (*CreateTableInput) AddGSINS

func (ct *CreateTableInput) AddGSINS(name, hashKey, rangeKey string)

func (*CreateTableInput) AddGSIS

func (ct *CreateTableInput) AddGSIS(name, hashKey string)

func (*CreateTableInput) AddGSISN

func (ct *CreateTableInput) AddGSISN(name, hashKey, rangeKey string)

func (*CreateTableInput) AddGSISS

func (ct *CreateTableInput) AddGSISS(name, hashKey, rangeKey string)

func (*CreateTableInput) AddLSIN

func (ct *CreateTableInput) AddLSIN(name, keyName string)

func (*CreateTableInput) AddLSIS

func (ct *CreateTableInput) AddLSIS(name, keyName string)

func (*CreateTableInput) AddRangeKeyN

func (ct *CreateTableInput) AddRangeKeyN(keyName string)

func (*CreateTableInput) AddRangeKeyS

func (ct *CreateTableInput) AddRangeKeyS(keyName string)

func (*CreateTableInput) AttributeList

func (ct *CreateTableInput) AttributeList() []*SDK.AttributeDefinition

func (*CreateTableInput) HasGSI

func (ct *CreateTableInput) HasGSI() bool

func (*CreateTableInput) HasLSI

func (ct *CreateTableInput) HasLSI() bool

func (*CreateTableInput) HasRangeKey

func (ct *CreateTableInput) HasRangeKey() bool

func (*CreateTableInput) ListGSI

func (ct *CreateTableInput) ListGSI() []*SDK.GlobalSecondaryIndex

func (*CreateTableInput) ListLSI

func (ct *CreateTableInput) ListLSI() []*SDK.LocalSecondaryIndex

func (*CreateTableInput) SetThroughput

func (ct *CreateTableInput) SetThroughput(r, w int64)

type DynamoError

type DynamoError struct {
	// contains filtered or unexported fields
}

func NewError

func NewError(msg string) *DynamoError

func NewErrorList

func NewErrorList(msgList []string) *DynamoError

func (*DynamoError) AddMessage

func (e *DynamoError) AddMessage(msg string)

func (DynamoError) Error

func (e DynamoError) Error() string

func (*DynamoError) HasError

func (e *DynamoError) HasError() bool

type DynamoIndex

type DynamoIndex struct {
	Name      string
	IndexType string
	KeySchema []*SDK.KeySchemaElement
}

DynamoIndex is wrapper struct for Index, used for storing indexes from GetTable's description

func NewDynamoIndex

func NewDynamoIndex(name, typ string, schema []*SDK.KeySchemaElement) *DynamoIndex

NewDynamoIndex returns initialized DynamoIndex

func (*DynamoIndex) GetHashKeyName

func (idx *DynamoIndex) GetHashKeyName() string

GetHashKeyName gets the name of hash key

func (*DynamoIndex) GetRangeKeyName

func (idx *DynamoIndex) GetRangeKeyName() string

GetRangeKeyName gets the name of range key if exist

type DynamoItem

type DynamoItem struct {
	// contains filtered or unexported fields
}

wrapped struct for DynamoDB Item (data of each row in RDB concept)

func NewItem

func NewItem() *DynamoItem

Create new empty Item

func (*DynamoItem) AddAttribute

func (item *DynamoItem) AddAttribute(name string, value Any)

Add a attribute to the Item

func (*DynamoItem) AddCondition

func (item *DynamoItem) AddCondition(name string, condition *SDK.ExpectedAttributeValue)

Add a condition for put

func (*DynamoItem) AddConditionEQ

func (item *DynamoItem) AddConditionEQ(name string, value Any)

Add a EQUAL condition for put

func (*DynamoItem) AddConditionExist

func (item *DynamoItem) AddConditionExist(name string)

Add a EXIST condition for put

func (*DynamoItem) AddConditionGE

func (item *DynamoItem) AddConditionGE(name string, value Any)

Add a GREATER THAN or EQUAL condition for put

func (*DynamoItem) AddConditionGT

func (item *DynamoItem) AddConditionGT(name string, value Any)

Add a GREATER THAN condition for put

func (*DynamoItem) AddConditionLE

func (item *DynamoItem) AddConditionLE(name string, value Any)

Add a LESS THAN or EQUAL condition for put

func (*DynamoItem) AddConditionLT

func (item *DynamoItem) AddConditionLT(name string, value Any)

Add a LESS THAN condition for put

func (*DynamoItem) AddConditionNE

func (item *DynamoItem) AddConditionNE(name string, value Any)

Add a NOT EQUAL condition for put

func (*DynamoItem) AddConditionNotExist

func (item *DynamoItem) AddConditionNotExist(name string)

Add a NOT EXIST condition for put

func (*DynamoItem) CountDown

func (item *DynamoItem) CountDown(name string, num int)

Atomic Counter

func (*DynamoItem) CountUp

func (item *DynamoItem) CountUp(name string, num int)

Atomic Counter

func (*DynamoItem) GetAttribute

func (item *DynamoItem) GetAttribute(name string) Any

Get a attribute from Item

type DynamoTable

type DynamoTable struct {
	// contains filtered or unexported fields
}

DynamoTable is a wapper struct for DynamoDB table

func (*DynamoTable) AddItem

func (t *DynamoTable) AddItem(item *DynamoItem)

AddItem adds an item to the write-waiting list (writeItem)

func (*DynamoTable) Delete

func (t *DynamoTable) Delete(values ...Any) error

delete item

func (*DynamoTable) DeleteAll

func (t *DynamoTable) DeleteAll() error

[CAUTION] only used this for developing, this performs scan all item and delete it each one by one

func (*DynamoTable) Desc

func (t *DynamoTable) Desc() (*TableDescription, error)

func (*DynamoTable) Get

func (t *DynamoTable) Get(values ...Any) ([]map[string]interface{}, error)

perform GetOne() or Query()

func (*DynamoTable) GetByIndex

func (t *DynamoTable) GetByIndex(idx string, values ...Any) ([]map[string]interface{}, error)

query using LSI or GSI

func (*DynamoTable) GetHashKeyName

func (t *DynamoTable) GetHashKeyName() string

get the name of hash key

func (*DynamoTable) GetOne

func (t *DynamoTable) GetOne(values ...Any) (map[string]interface{}, error)

GetOne retrieves a single item by GetOne(HashKey [, RangeKey])

func (*DynamoTable) GetRangeKeyName

func (t *DynamoTable) GetRangeKeyName() string

get the name of range key if exist

func (*DynamoTable) NewQuery

func (t *DynamoTable) NewQuery() *Query

func (*DynamoTable) Put

func (t *DynamoTable) Put() error

excecute write operation in the write-waiting list (writeItem)

func (*DynamoTable) Query

func (t *DynamoTable) Query(in *SDK.QueryInput) ([]map[string]interface{}, error)

get mapped-items with Query operation

func (*DynamoTable) Scan

func (t *DynamoTable) Scan() ([]map[string]interface{}, error)

get mapped-items with Scan operation

func (*DynamoTable) UpdateReadThroughput

func (t *DynamoTable) UpdateReadThroughput(v int64) error

func (*DynamoTable) UpdateThroughput

func (t *DynamoTable) UpdateThroughput(r int64, w int64) error

func (*DynamoTable) UpdateWriteThroughput

func (t *DynamoTable) UpdateWriteThroughput(v int64) error

type Query

type Query struct {
	// contains filtered or unexported fields
}

func (*Query) AndBETWEEN

func (q *Query) AndBETWEEN(key string, from, to interface{})

func (*Query) AndEQ

func (q *Query) AndEQ(key string, val interface{})

func (*Query) AndGE

func (q *Query) AndGE(key string, val interface{})

func (*Query) AndGT

func (q *Query) AndGT(key string, val interface{})

func (*Query) AndLE

func (q *Query) AndLE(key string, val interface{})

func (*Query) AndLT

func (q *Query) AndLT(key string, val interface{})

func (*Query) Count

func (q *Query) Count() (*QueryResult, error)

func (*Query) HasCondition

func (q *Query) HasCondition() bool

func (*Query) HasIndex

func (q *Query) HasIndex() bool

func (*Query) HasLimit

func (q *Query) HasLimit() bool

func (*Query) Index

func (q *Query) Index(v string)

func (*Query) Limit

func (q *Query) Limit(i int64)

func (*Query) Query

func (q *Query) Query() (*QueryResult, error)

type QueryCondition

type QueryCondition struct {
	// contains filtered or unexported fields
}

wrapped struct for condition on Query operation

func NewQueryCondition

func NewQueryCondition() *QueryCondition

Create new QueryCondition struct

func (*QueryCondition) Add

func (c *QueryCondition) Add(name string, condition SDK.Condition)

Add a condition for Query operation

func (*QueryCondition) AddEQ

func (c *QueryCondition) AddEQ(name string, value Any)

Add a EQUAL condition for Query operation

func (*QueryCondition) AddGE

func (c *QueryCondition) AddGE(name string, value Any)

Add a GREATER THAN or EQUAL condition for Query operation

func (*QueryCondition) AddGT

func (c *QueryCondition) AddGT(name string, value Any)

Add a GREATER THAN condition for Query operation

func (*QueryCondition) AddLE

func (c *QueryCondition) AddLE(name string, value Any)

Add a LESS THAN or EQUAL condition for Query operation

func (*QueryCondition) AddLT

func (c *QueryCondition) AddLT(name string, value Any)

Add a LESS THAN condition for Query operation

func (*QueryCondition) AddNE

func (c *QueryCondition) AddNE(name string, value Any)

Add a NOT EQUAL condition for Query operation

func (*QueryCondition) UseIndex

func (c *QueryCondition) UseIndex(name string)

Set an Indexname for Query operation

type QueryResult

type QueryResult struct {
	Items            []map[string]*SDK.AttributeValue
	LastEvaluatedKey map[string]*SDK.AttributeValue
	Count            int64
	ScannedCount     int64
}

func (QueryResult) ToSliceMap

func (r QueryResult) ToSliceMap() []map[string]interface{}

type TableDescription

type TableDescription struct {
	*SDK.TableDescription
}

TableDescription is wrapper struct fro SDK.TableDescription

func (TableDescription) GetItemCount

func (d TableDescription) GetItemCount() int64

func (TableDescription) GetKeyAttributes

func (d TableDescription) GetKeyAttributes() map[string]string

func (TableDescription) GetNumberOfDecreasesToday

func (d TableDescription) GetNumberOfDecreasesToday() int64

func (TableDescription) GetReadCapacityUnits

func (d TableDescription) GetReadCapacityUnits() int64

func (TableDescription) GetTableName

func (d TableDescription) GetTableName() string

func (TableDescription) GetTableStatus

func (d TableDescription) GetTableStatus() string

func (TableDescription) GetWriteCapacityUnits

func (d TableDescription) GetWriteCapacityUnits() int64

func (TableDescription) IsActive

func (d TableDescription) IsActive() bool

Jump to

Keyboard shortcuts

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