schema

package
v0.0.0-...-b5e4ba5 Latest Latest
Warning

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

Go to latest
Published: May 18, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package schema contains the structs that describe the database table and its fields.

Index

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 Key

type Key struct {
	Name string
	Type KeyType
}

Key describes a key attribute by providing its key type.

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.

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.

const (
	ActiveStatus   Status = "ACTIVE"
	CreatingStatus Status = "CREATING"
	DeletingStatus Status = "DELETING"
	UpdatingStatus Status = "UPDATING"
	UnknownStatus  Status = "UNKNOWN"
)

A table or a global secondary index can only be used if its current status is active.

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

func (t *Table) AddAttributes(attributes []Attribute)

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

func (t *Table) CreationDate() time.Time

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) ItemCount

func (t *Table) ItemCount() int

ItemCount returns the number of items in this table.

func (*Table) RemoveGlobalSecondaryIndex

func (t *Table) RemoveGlobalSecondaryIndex(indexName string)

RemoveGlobalSecondaryIndex removes the index with the given name from the table.

func (*Table) RemoveLocalSecondaryIndex

func (t *Table) RemoveLocalSecondaryIndex(indexName string)

RemoveLocalSecondaryIndex removes a local secondary index with the given name from the table.

func (*Table) Size

func (t *Table) Size() int

Size returns the table size in bytes.

func (*Table) Status

func (t *Table) Status() Status

Status return the status of this table.

type Throughput

type Throughput struct {
	Read  int
	Write int
}

Throughput contains the provisioned throughput for a given table or global secondary index.

Jump to

Keyboard shortcuts

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