Documentation ¶
Overview ¶
Package schema contains the structs that describe the database table and its fields.
Index ¶
- type Attribute
- type AttributeType
- type Key
- type KeyType
- type Projection
- type ProjectionType
- type SecondaryIndex
- type Status
- type Table
- func (t *Table) AddAttributes(attributes []Attribute)
- func (t *Table) AddGlobalSecondaryIndex(index SecondaryIndex)
- func (t *Table) AddLocalSecondaryIndex(index SecondaryIndex)
- func (t *Table) CreationDate() time.Time
- func (t *Table) GetGlobalSecondaryIndex(indexName string) (SecondaryIndex, error)
- func (t *Table) GetLocalSecondaryIndex(indexName string) (SecondaryIndex, error)
- func (t *Table) ItemCount() int
- func (t *Table) RemoveGlobalSecondaryIndex(indexName string)
- func (t *Table) RemoveLocalSecondaryIndex(indexName string)
- func (t *Table) Size() int
- func (t *Table) Status() Status
- type Throughput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
type Attribute struct { Name string Type AttributeType }
Attribute describes a key attribute by providing its attribute type.
type AttributeType ¶
type AttributeType string
AttributeType is the data type for key attributes.
const ( BinaryType AttributeType = "B" NumberType AttributeType = "N" StringType AttributeType = "S" )
A key attribute can only be a number, string, or binary data.
type KeyType ¶
type KeyType string
KeyType is the key type of an attribute.
const ( HashKey KeyType = db.KeyTypeHash RangeKey KeyType = db.KeyTypeRange )
A key attribute can only be a hash (partition) or range (sort) key.
type Projection ¶
type Projection struct { Type ProjectionType Include []string }
Projection specifies which attributes are projected from a table into an index.
type ProjectionType ¶
type ProjectionType string
ProjectionType specifies which set of attributes are projected into the index.
const ( ProjectAll ProjectionType = db.ProjectionTypeAll ProjectInclude ProjectionType = db.ProjectionTypeInclude ProjectKeysOnly ProjectionType = db.ProjectionTypeKeysOnly )
ProjectKeysOnly is the default projection type. It only projects the primary key and the secondary index key. ProjectInclude projects only the specified attributes. The names of the projected attributes are in Projection.Include field. ProjectAll projects all attributes from the table to the index.
type SecondaryIndex ¶
type SecondaryIndex struct { Name string Key []Key Projection Projection Throughput Throughput // contains filtered or unexported fields }
SecondaryIndex contains the properties of an index.
func (*SecondaryIndex) ItemCount ¶
func (idx *SecondaryIndex) ItemCount() int
ItemCount returns the number of items in this index.
func (*SecondaryIndex) Size ¶
func (idx *SecondaryIndex) Size() int
Size returns the index size in bytes.
func (*SecondaryIndex) Status ¶
func (idx *SecondaryIndex) Status() Status
Status returns the current state of the index.
type Status ¶
type Status string
Status represents the current state of a table or a global secondary index.
type Table ¶
type Table struct { Name string Key []Key Attributes []Attribute Throughput Throughput LocalSecondaryIndexes []SecondaryIndex GlobalSecondaryIndexes []SecondaryIndex StreamEnabled bool // contains filtered or unexported fields }
Table contains the properties of a table.
func GetSchema ¶
func GetSchema(item interface{}) *Table
GetSchema is a utility function that returns an incomplete table schema from the given item. If a complete table schema is needed, use NewTable instead.
func NewTable ¶
func NewTable( tableName string, item interface{}, throughput map[string]Throughput) *Table
NewTable returns a new table from an item. item must be a struct or a pointer to struct with properly tagged fields. throughput should contain the provisioned throughput for the given table and any additional secondary global indices.
func (*Table) AddAttributes ¶
AddAttributes appends the given attributes to the table's attributes. If an attribute with the same name is already present in the table, then it will be replaced by the given attribute.
func (*Table) AddGlobalSecondaryIndex ¶
func (t *Table) AddGlobalSecondaryIndex(index SecondaryIndex)
AddGlobalSecondaryIndex adds a global secondary index to the table. If an index with the same name is already present, then it will be replaced by the given index.
func (*Table) AddLocalSecondaryIndex ¶
func (t *Table) AddLocalSecondaryIndex(index SecondaryIndex)
AddLocalSecondaryIndex adds a new local secondary index to the table. This will replace any index with the same name.
func (*Table) CreationDate ¶
CreationDate returns the date and time the table was created in unix epoch time.
func (*Table) GetGlobalSecondaryIndex ¶
func (t *Table) GetGlobalSecondaryIndex(indexName string) (SecondaryIndex, error)
GetGlobalSecondaryIndex returns the global index with the given name.
func (*Table) GetLocalSecondaryIndex ¶
func (t *Table) GetLocalSecondaryIndex(indexName string) (SecondaryIndex, error)
GetLocalSecondaryIndex returns the local index with the given name.
func (*Table) RemoveGlobalSecondaryIndex ¶
RemoveGlobalSecondaryIndex removes the index with the given name from the table.
func (*Table) RemoveLocalSecondaryIndex ¶
RemoveLocalSecondaryIndex removes a local secondary index with the given name from the table.
type Throughput ¶
Throughput contains the provisioned throughput for a given table or global secondary index.