Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromDynamo ¶
func FromDynamo(item DynamoItem, v interface{}) (err error)
FromDynamo takes a map of DynamoDB attributes and converts it into a map or struct in basic JSON format.
If v points to a struct, we first convert it to a basic map, then JSON encode/decode it to convert to a struct. This can/should be optimized later.
Types ¶
type DynamoAttribute ¶
type DynamoAttribute struct { S *string `json:",omitempty"` // pointer so we can represent the zero-value N string `json:",omitempty"` BOOL *bool `json:",omitempty"` // pointer so we can represent the zero-value NULL bool `json:",omitempty"` M map[string]*DynamoAttribute `json:",omitempty"` L []*DynamoAttribute `json:",omitempty"` }
A DynamoAttribute represents the union of possible DynamoDB attribute values. See http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeValue.html
Since the intention is to use this with JSON documents (or structs representing JSON documents), the binary and set types have been omitted.
type DynamoItem ¶
type DynamoItem map[string]*DynamoAttribute
A DynamoItem represents a the top level item stored in DyanmoDB.
func ToDynamo ¶
func ToDynamo(in interface{}) (item DynamoItem, err error)
ToDynamo accepts a map or struct in basic JSON format and converts it to a map which can be JSON-encoded into the DynamoDB format.
If in is a struct, we first JSON encode/decode it to get the data as a map. This can/should be optimized later.