dynamodb

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProjectionTypeAll      = "ALL"
	ProjectionTypeKeysOnly = "KEYS_ONLY"
)

projection type of the index. see: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Projection.html

View Source
const (
	ComparisonOperatorEQ = "EQ"
	ComparisonOperatorNE = "NE"
	ComparisonOperatorGT = "GT"
	ComparisonOperatorLT = "LT"
	ComparisonOperatorGE = "GE"
	ComparisonOperatorLE = "LE"
)

comparison operators

View Source
const (
	KeyTypeHash  = "HASH"
	KeyTypeRange = "RANGE"
)

key type name for DynamoDB Index.

Variables

This section is empty.

Functions

func Marshal

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

Marshal converts map data to DynamoDB Item data.

func MarshalStringSlice

func MarshalStringSlice(item interface{}) []*string

MarshalStringSlice converts string slice to DynamoDB Item data.

func NewAttributeDefinition

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

NewAttributeDefinition returns initialized *SDK.AttributeDefinition.

func NewAttributeDefinitions

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

NewAttributeDefinitions returns multiple AttributeDefinition 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 NewExpectedCondition

func NewExpectedCondition(value interface{}, operator string) *SDK.ExpectedAttributeValue

NewExpectedCondition returns *SDK.ExpectedAttributeValue with ComparisonOperator and value.

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

NewHashKeyElement creates initialized *SDK.KeySchemaElement for HashKey.

func NewKeyElement

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

NewKeyElement creates initialized *SDK.KeySchemaElement.

func NewKeySchema

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

NewKeySchema creates new []*SDK.KeySchemaElement.

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 NewRangeKeyElement

func NewRangeKeyElement(keyName string) *SDK.KeySchemaElement

NewRangeKeyElement creates initialized *SDK.KeySchemaElement for RangeKey.

func NewStringAttribute

func NewStringAttribute(attrName string) *SDK.AttributeDefinition

NewStringAttribute returns a table AttributeDefinition for string

func UnmarshalAttributeValue added in v1.0.0

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

UnmarshalAttributeValue converts DynamoDB Item to map data.

Types

type Condition added in v1.0.0

type Condition struct {
	Condition string
	Key       string
	Value     interface{}
	SubValue  interface{}
	OR        bool
	// contains filtered or unexported fields
}

Condition contains condition.

type ConditionList added in v1.0.0

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

ConditionList contains multiple condition.

func NewConditionList added in v1.0.0

func NewConditionList(keyAttributes map[string]string) *ConditionList

NewConditionList returns initialized *ConditionList.

func (*ConditionList) AndBETWEEN added in v1.0.0

func (c *ConditionList) AndBETWEEN(key string, from, to interface{})

AndBETWEEN adds BETWEEN condition.

func (*ConditionList) AndEQ added in v1.0.0

func (c *ConditionList) AndEQ(key string, val interface{})

AndEQ adds EQ(equal) condition.

func (*ConditionList) AndGE added in v1.0.0

func (c *ConditionList) AndGE(key string, val interface{})

AndGE adds GE(greater equal than) condition.

func (*ConditionList) AndGT added in v1.0.0

func (c *ConditionList) AndGT(key string, val interface{})

AndGT adds GT(greater than) condition.

func (*ConditionList) AndLE added in v1.0.0

func (c *ConditionList) AndLE(key string, val interface{})

AndLE adds LE(less equal than) condition.

func (*ConditionList) AndLT added in v1.0.0

func (c *ConditionList) AndLT(key string, val interface{})

AndLT adds LT(less than) condition.

func (*ConditionList) FilterBETWEEN added in v1.0.0

func (c *ConditionList) FilterBETWEEN(key string, from, to interface{})

FilterBETWEEN adds BETWEEN filter.

func (*ConditionList) FilterEQ added in v1.0.0

func (c *ConditionList) FilterEQ(key string, val interface{})

FilterEQ adds EQ(equal) filter.

func (*ConditionList) FilterGE added in v1.0.0

func (c *ConditionList) FilterGE(key string, val interface{})

FilterGE adds GE(greater equal than) filter.

func (*ConditionList) FilterGT added in v1.0.0

func (c *ConditionList) FilterGT(key string, val interface{})

FilterGT adds GT(greater than) filter.

func (*ConditionList) FilterLE added in v1.0.0

func (c *ConditionList) FilterLE(key string, val interface{})

FilterLE adds LE(less equal than) filter.

func (*ConditionList) FilterLT added in v1.0.0

func (c *ConditionList) FilterLT(key string, val interface{})

FilterLT adds LT(less than) filter.

func (*ConditionList) FormatCondition added in v1.0.0

func (c *ConditionList) FormatCondition() *string

FormatCondition returns string pointer for KeyConditionExpression.

func (*ConditionList) FormatFilter added in v1.0.0

func (c *ConditionList) FormatFilter() *string

FormatFilter returns string pointer for KeyConditionExpression.

func (*ConditionList) FormatNames added in v1.0.0

func (c *ConditionList) FormatNames() map[string]*string

FormatNames returns the parameter for ExpressionAttributeNames.

func (*ConditionList) FormatValues added in v1.0.0

func (c *ConditionList) FormatValues() map[string]*SDK.AttributeValue

FormatValues returns the parameter for ExpressionAttributeValues.

func (*ConditionList) HasCondition added in v1.0.0

func (c *ConditionList) HasCondition() bool

HasCondition checks if at least one condition is set or not.

func (*ConditionList) HasFilter added in v1.0.0

func (c *ConditionList) HasFilter() bool

HasFilter checks if at least one filter is set or not.

func (*ConditionList) HasIndex added in v1.0.0

func (c *ConditionList) HasIndex() bool

HasIndex checks if the index is set or not.

func (*ConditionList) HasLimit added in v1.0.0

func (c *ConditionList) HasLimit() bool

HasLimit checks if limit number is set or not.

func (*ConditionList) SetConsistent added in v1.0.0

func (c *ConditionList) SetConsistent(b bool)

SetConsistent sets consistent read flag.

func (*ConditionList) SetIndex added in v1.0.0

func (c *ConditionList) SetIndex(v string)

SetIndex sets index to use.

func (*ConditionList) SetLimit added in v1.0.0

func (c *ConditionList) SetLimit(i int64)

SetLimit sets limit number.

func (*ConditionList) SetStartKey added in v1.0.0

func (c *ConditionList) SetStartKey(startKey map[string]*SDK.AttributeValue)

SetStartKey sets ExclusiveStartKey.

type DynamoDB added in v1.0.0

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

DynamoDB has DynamoDB client and table list.

func New added in v1.0.0

func New(conf config.Config) (*DynamoDB, error)

New returns initializesvc *DynamoDB.

func (*DynamoDB) CreateTable added in v1.0.0

func (svc *DynamoDB) CreateTable(design *TableDesign) error

CreateTable new DynamoDB table

func (*DynamoDB) DoQuery added in v1.0.0

func (svc *DynamoDB) DoQuery(in *SDK.QueryInput) (*QueryResult, error)

DoQuery executes `Query` operation and get mapped-items.

func (*DynamoDB) Errorf added in v1.0.0

func (svc *DynamoDB) Errorf(format string, v ...interface{})

Errorf logging error information.

func (*DynamoDB) ForceDeleteTable added in v1.0.0

func (svc *DynamoDB) ForceDeleteTable(name string) error

ForceDeleteTable deletes DynamoDB table.

func (*DynamoDB) GetTable added in v1.0.0

func (svc *DynamoDB) GetTable(name string) (*Table, error)

GetTable returns *Table.

func (*DynamoDB) Infof added in v1.0.0

func (svc *DynamoDB) Infof(format string, v ...interface{})

Infof logging information.

func (*DynamoDB) ListTables added in v1.0.0

func (svc *DynamoDB) ListTables() ([]string, error)

ListTables gets the list of DynamoDB table.

func (*DynamoDB) PutAll added in v1.0.0

func (svc *DynamoDB) PutAll() error

PutAll executes put operation for all tables in write spool list.

func (*DynamoDB) SetLogger added in v1.0.0

func (svc *DynamoDB) SetLogger(logger log.Logger)

SetLogger sets logger.

type PutItem added in v1.0.0

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

PutItem is wrapped struct for DynamoDB Item to put.

func NewPutItem added in v1.0.0

func NewPutItem() *PutItem

NewPutItem returns initialized *PutItem.

func (*PutItem) AddAttribute added in v1.0.0

func (item *PutItem) AddAttribute(name string, value interface{})

AddAttribute adds an attribute to the PutItem.

func (*PutItem) AddConditionEQ added in v1.0.0

func (item *PutItem) AddConditionEQ(name string, value interface{})

AddConditionEQ adds a EQUAL condition.

func (*PutItem) AddConditionExist added in v1.0.0

func (item *PutItem) AddConditionExist(name string)

AddConditionExist adds a EXIST condition.

func (*PutItem) AddConditionGE added in v1.0.0

func (item *PutItem) AddConditionGE(name string, value interface{})

AddConditionGE adds a GREATER THAN or EQUAL condition.

func (*PutItem) AddConditionGT added in v1.0.0

func (item *PutItem) AddConditionGT(name string, value interface{})

AddConditionGT adds a GREATER THAN condition.

func (*PutItem) AddConditionLE added in v1.0.0

func (item *PutItem) AddConditionLE(name string, value interface{})

AddConditionLE adds a LESS THAN or EQUAL condition.

func (*PutItem) AddConditionLT added in v1.0.0

func (item *PutItem) AddConditionLT(name string, value interface{})

AddConditionLT adds a LESS THAN condition.

func (*PutItem) AddConditionNE added in v1.0.0

func (item *PutItem) AddConditionNE(name string, value interface{})

AddConditionNE adds a NOT EQUAL condition.

func (*PutItem) AddConditionNotExist added in v1.0.0

func (item *PutItem) AddConditionNotExist(name string)

AddConditionNotExist adds a NOT EXIST condition.

func (*PutItem) CountDown added in v1.0.0

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

CountDown counts down the value.

func (*PutItem) CountUp added in v1.0.0

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

CountUp counts up the value.

func (*PutItem) GetAttribute added in v1.0.0

func (item *PutItem) GetAttribute(name string) interface{}

GetAttribute gets an attribute from PutItem.

type QueryResult added in v0.9.2

type QueryResult struct {
	Items            []map[string]*SDK.AttributeValue
	LastEvaluatedKey map[string]*SDK.AttributeValue
	Count            int64
	ScannedCount     int64
	// contains filtered or unexported fields
}

QueryResult is struct for result of Query operation.

func (QueryResult) ToSliceMap added in v0.9.2

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

ToSliceMap converts result to slice of map.

func (QueryResult) Unmarshal added in v1.0.0

func (r QueryResult) Unmarshal(v interface{}) error

Unmarshal parse DynamoDB item data and mapping value to given slice pointer sturct.

e.g. err = Unmarshal(&[]*yourStruct)

type Table added in v1.0.0

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

Table is a wapper struct for DynamoDB table

func NewTable added in v1.0.0

func NewTable(svc *DynamoDB, name string) (*Table, error)

NewTable returns initialized *Table.

func (*Table) AddItem added in v1.0.0

func (t *Table) AddItem(item *PutItem)

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

func (*Table) Count added in v1.0.0

func (t *Table) Count(cond *ConditionList) (*QueryResult, error)

Count executes Query operation and get Count.

func (*Table) Delete added in v1.0.0

func (t *Table) Delete(hashValue interface{}, rangeValue ...interface{}) error

Delete deletes the item.

func (*Table) Design added in v1.0.0

func (t *Table) Design() (*TableDesign, error)

Design returns table design.

func (*Table) ForceDeleteAll added in v1.0.0

func (t *Table) ForceDeleteAll() error

ForceDeleteAll deltes all data in the table. This performs scan all item and delete it each one by one.

func (*Table) GetOne added in v1.0.0

func (t *Table) GetOne(hashValue interface{}, rangeValue ...interface{}) (map[string]interface{}, error)

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

func (*Table) NewConditionList added in v1.0.0

func (t *Table) NewConditionList() *ConditionList

NewConditionList returns initialized *ConditionList.

func (*Table) Put added in v1.0.0

func (t *Table) Put() error

Put excecutes put operation from the write-waiting list (writeItem)

func (*Table) Query added in v1.0.0

func (t *Table) Query(cond *ConditionList) (*QueryResult, error)

Query executes Query operation.

func (*Table) Scan added in v1.0.0

func (t *Table) Scan() (*QueryResult, error)

Scan executes Scan operation.

func (*Table) ScanWithCondition added in v1.0.0

func (t *Table) ScanWithCondition(cond *ConditionList) (*QueryResult, error)

ScanWithCondition executes Scan operation with given condition.

func (*Table) UpdateReadThroughput added in v1.0.0

func (t *Table) UpdateReadThroughput(r int64) error

UpdateReadThroughput updates the read ProvisionedThroughput.

func (*Table) UpdateThroughput added in v1.0.0

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

UpdateThroughput updates the r/w ProvisionedThroughput.

func (*Table) UpdateWriteThroughput added in v1.0.0

func (t *Table) UpdateWriteThroughput(w int64) error

UpdateWriteThroughput updates the write ProvisionedThroughput.

type TableDesign added in v1.0.0

type TableDesign struct {
	HashKey    *SDK.KeySchemaElement
	RangeKey   *SDK.KeySchemaElement
	LSI        []*SDK.LocalSecondaryIndex
	GSI        []*SDK.GlobalSecondaryIndex
	Attributes map[string]*SDK.AttributeDefinition
	// contains filtered or unexported fields
}

TableDesign is struct for table schema.

func NewTableDesignWithHashKeyN added in v1.0.0

func NewTableDesignWithHashKeyN(tableName, keyName string) *TableDesign

NewTableDesignWithHashKeyN returns create table request data for number hashkey

func NewTableDesignWithHashKeyS added in v1.0.0

func NewTableDesignWithHashKeyS(tableName, keyName string) *TableDesign

NewTableDesignWithHashKeyS returns create table request data for string hashkey

func (*TableDesign) AddGSIN added in v1.0.0

func (d *TableDesign) AddGSIN(name, hashKey string) error

AddGSIN adds GlobalSecondaryIndex; HashKey=Number.

func (*TableDesign) AddGSINN added in v1.0.0

func (d *TableDesign) AddGSINN(name, hashKey, rangeKey string) error

AddGSINN adds GlobalSecondaryIndex; HashKey=Number, RangeKey=Number.

func (*TableDesign) AddGSINS added in v1.0.0

func (d *TableDesign) AddGSINS(name, hashKey, rangeKey string) error

AddGSINS adds GlobalSecondaryIndex; HashKey=Number, RangeKey=String.

func (*TableDesign) AddGSIS added in v1.0.0

func (d *TableDesign) AddGSIS(name, hashKey string) error

AddGSIS adds GlobalSecondaryIndex; HashKey=String.

func (*TableDesign) AddGSISN added in v1.0.0

func (d *TableDesign) AddGSISN(name, hashKey, rangeKey string) error

AddGSISN adds GlobalSecondaryIndex; HashKey=String, RangeKey=Number.

func (*TableDesign) AddGSISS added in v1.0.0

func (d *TableDesign) AddGSISS(name, hashKey, rangeKey string) error

AddGSISS adds GlobalSecondaryIndex; HashKey=String, RangeKey=String.

func (*TableDesign) AddLSIN added in v1.0.0

func (d *TableDesign) AddLSIN(name, keyName string)

AddLSIN adds LocalSecondaryIndex for Number type.

func (*TableDesign) AddLSIS added in v1.0.0

func (d *TableDesign) AddLSIS(name, keyName string)

AddLSIS adds LocalSecondaryIndex for String type.

func (*TableDesign) AddRangeKeyN added in v1.0.0

func (d *TableDesign) AddRangeKeyN(keyName string)

AddRangeKeyN adds range key for Number type.

func (*TableDesign) AddRangeKeyS added in v1.0.0

func (d *TableDesign) AddRangeKeyS(keyName string)

AddRangeKeyS adds range key for String type.

func (*TableDesign) AttributeList added in v1.0.0

func (d *TableDesign) AttributeList() []*SDK.AttributeDefinition

AttributeList returns list of *SDK.AttributeDefinition.

func (*TableDesign) CreateTableInput added in v1.0.0

func (d *TableDesign) CreateTableInput() *SDK.CreateTableInput

CreateTableInput creates *SDK.CreateTableInput from the table design.

func (*TableDesign) GetHashKeyName added in v1.0.0

func (d *TableDesign) GetHashKeyName() string

GetHashKeyName returns attribute name of the HashKey.

func (*TableDesign) GetItemCount added in v1.0.0

func (d *TableDesign) GetItemCount() int64

GetItemCount returns items count on this table.

func (*TableDesign) GetKeyAttributes added in v1.0.0

func (d *TableDesign) GetKeyAttributes() map[string]string

GetKeyAttributes returns KeyAttributes.

func (*TableDesign) GetName added in v1.0.0

func (d *TableDesign) GetName() string

GetName returns table name.

func (*TableDesign) GetNumberOfDecreasesToday added in v1.0.0

func (d *TableDesign) GetNumberOfDecreasesToday() int64

GetNumberOfDecreasesToday returns NumberOfDecreasesToday for throughput.

func (*TableDesign) GetRangeKeyName added in v1.0.0

func (d *TableDesign) GetRangeKeyName() string

GetRangeKeyName returns attribute name of the RangeKey.

func (*TableDesign) GetReadCapacity added in v1.0.0

func (d *TableDesign) GetReadCapacity() int64

GetReadCapacity returns read capacity.

func (*TableDesign) GetStatus added in v1.0.0

func (d *TableDesign) GetStatus() string

GetStatus returns table status.

func (*TableDesign) GetWriteCapacity added in v1.0.0

func (d *TableDesign) GetWriteCapacity() int64

GetWriteCapacity returns write capacity.

func (*TableDesign) HasGSI added in v1.0.0

func (d *TableDesign) HasGSI() bool

HasGSI checks if at least one GlobalSecondaryIndex is set or not.

func (*TableDesign) HasLSI added in v1.0.0

func (d *TableDesign) HasLSI() bool

HasLSI checks if at least one LocalSecondaryIndex is set or not.

func (*TableDesign) HasRangeKey added in v1.0.0

func (d *TableDesign) HasRangeKey() bool

HasRangeKey checks if range key is set or not.

func (*TableDesign) IsActive added in v1.0.0

func (d *TableDesign) IsActive() bool

IsActive checks if the table status is active or not.

func (*TableDesign) ListGSI added in v1.0.0

func (d *TableDesign) ListGSI() []*SDK.GlobalSecondaryIndex

ListGSI returns multiple GlobalSecondaryIndex.

func (*TableDesign) ListLSI added in v1.0.0

func (d *TableDesign) ListLSI() []*SDK.LocalSecondaryIndex

ListLSI returns multiple LocalSecondaryIndex.

func (*TableDesign) SetThroughput added in v1.0.0

func (d *TableDesign) SetThroughput(r, w int64)

SetThroughput sets read and write throughput.

Jump to

Keyboard shortcuts

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