Documentation ¶
Index ¶
- func CheckRowCount(db *dynamodb.DynamoDB, tableName string) int
- func CheckRows(db *dynamodb.DynamoDB, tableName string) ([]Row, ValueDefiner)
- func Create(cfg *aws.Config, schema []Schema, abortOnErr bool) error
- func Delete(cfg *aws.Config, schema []Schema, abortOnErr bool) error
- func Int(item map[string]*dynamodb.AttributeValue, key string) int
- func SetInt(item map[string]*dynamodb.AttributeValue, key string, val int)
- func SetStr(item map[string]*dynamodb.AttributeValue, key string, val string)
- func Str(item map[string]*dynamodb.AttributeValue, key string) string
- type DefFunc
- type Row
- type Schema
- type Table
- type ValueDefiner
- type ValueReader
- type ValueWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRowCount ¶
CheckRowCount returns the number of records in a table.
func CheckRows ¶
func CheckRows(db *dynamodb.DynamoDB, tableName string) ([]Row, ValueDefiner)
CheckRows returns a Row accessor for every row in a table. The order of rows is unspecified. If an error occurs, the rows will be nil. The returned ValueDefiner can be used to define access to custom types across all rows.
func Create ¶
Create makes sure that all of the schemas exist. If abortOnErr is false, it iterates through all schemas even if one returns an error. This is generally what you want to do since each table schema is independent, and it makes calling this function idempotent.
func Delete ¶
Delete makes sure that none of the schemas exist. If abortOnErr is false, it continues deleting even if one causes an error. This is generally what you want to do, since each table is independent. It also makes this function idempotent.
func Int ¶
func Int(item map[string]*dynamodb.AttributeValue, key string) int
Int returns an int from a DynamoDB attribute value. If anything goes wrong reading or parsing the value, 0 is returned.
func SetInt ¶
func SetInt(item map[string]*dynamodb.AttributeValue, key string, val int)
SetInt stores an int attribute.
Types ¶
type Row ¶
type Row struct {
ValueReader
}
Row is a generic accessor for any dynamodb row. It implements ValueReader, so all of the convenient methods defined there are available.
type Schema ¶
type Schema interface { // Create ensures that the table(s) exist. It should return an error if // the table already exists or there is any problem creating it. Create(*aws.Config) error // Delete ensures that the table(s) do not exist. It should return an // error if the table cannot be deleted or if it does not exist. Delete(*aws.Config) error }
Schema is the interface for managing table schemas.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a convient wrapper over any DynamoDB table.
func CheckTable ¶
CheckTable initializes a new wrapper over the table.
func (Table) Rows ¶
func (t Table) Rows() ([]Row, ValueDefiner)
Rows returns a simple accessor for each row in the table. The rows are returned in no particular order. The returned ValueDefiner can be used to initialize access to complex values.
type ValueDefiner ¶
type ValueDefiner interface { // Def defines a custom conversion, accessible via Get. Def(key string, f DefFunc) }
ValueDefiner lets you define accessors for custom types.
type ValueReader ¶
type ValueReader interface { // Str returns a string value from the item. Str(key string) string // Int returns an int value from the item. Int(key string) int // Get returns the value from a custom-defined field. Get(key string) interface{} // ValueDefiner provides Def() ValueDefiner }
ValueReader defines access to different types of value.
func NewValueReader ¶
func NewValueReader(item map[string]*dynamodb.AttributeValue) ValueReader
NewValueReader initializes a ValueReader over an item.
type ValueWriter ¶
type ValueWriter struct {
// contains filtered or unexported fields
}
ValueWriter lets you easily set values in an DynamoDB AttributeValue map.
func NewValueWriter ¶
func NewValueWriter(item map[string]*dynamodb.AttributeValue) ValueWriter
NewValueWriter initializes a ValueWriter over an item.
func (ValueWriter) Int ¶
func (w ValueWriter) Int(key string, val int)
Int writes an int values to the item.
func (ValueWriter) Str ¶
func (w ValueWriter) Str(key string, val string)
Str writes a string value to the item.