dynamodb

package module
v0.0.0-...-21fd97e Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2015 License: MIT Imports: 11 Imported by: 0

README

dynamodb-helpers

DynamoDB AttributeValue encode/decode adapted from encoding/json

This is currently used in production in a private AWS library.

    type MyNestedStruct struct {
        Field3 int
    }

    type MyStruct struct {
        Field1 int
        Field2 map[string]MyNestedStruct
    }

    m1 := &MyStruct{
        Field1: 10,
        Field2: map[string]MyNestedStruct{
            "foo": MyNestedStruct{10},
            "bar": MyNestedStruct{20},
        },
    }

    // attrValue is now a complete AttributeValue object
    attrValue, err := EncodeToAttributeValue(m1)
    
    m2 := &MyStruct{}
    err = DecodeAttributeValueToInterface(attrValue, m2)

    // m1 == m2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JSONMarshalerType = reflect.TypeOf((*json.Marshaler)(nil)).Elem()
View Source
var JSONUnmarshalerType = reflect.TypeOf((*json.Marshaler)(nil)).Elem()
View Source
var TextMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem()
View Source
var TextUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()

Functions

func Decode

func Decode(data []byte, item interface{}) error

func DecodeAttributeValueToInterface

func DecodeAttributeValueToInterface(attr *AttributeValue, item interface{}) error

func Encode

func Encode(item interface{}) ([]byte, error)

Types

type AttributeValue

type AttributeValue struct {
	B    []byte
	BOOL *bool
	S    *string
	N    *string
	NULL *bool
	M    AttributeValueMap
	L    []*AttributeValue
}

func DecodeToAttributeValue

func DecodeToAttributeValue(data []byte) (*AttributeValue, error)

func EncodeToAttributeValue

func EncodeToAttributeValue(item interface{}) (*AttributeValue, error)

func MustEncodeToAttributeValue

func MustEncodeToAttributeValue(item interface{}) *AttributeValue

func (*AttributeValue) IsValid

func (a *AttributeValue) IsValid() bool

func (*AttributeValue) MarshalJSON

func (a *AttributeValue) MarshalJSON() ([]byte, error)

func (*AttributeValue) Type

type AttributeValueMap

type AttributeValueMap map[string]*AttributeValue

type AttributeValueType

type AttributeValueType int
const (
	INVALID_ATTRIBUTEVALUE_TYPE AttributeValueType = iota

	B
	BOOL
	L
	M
	N
	NULL
	S
)

func (AttributeValueType) MarshalJSON

func (a AttributeValueType) MarshalJSON() ([]byte, error)

func (AttributeValueType) String

func (a AttributeValueType) String() string

func (*AttributeValueType) UnmarshalJSON

func (a *AttributeValueType) UnmarshalJSON(d []byte) error

type DecodeError

type DecodeError struct {
	Message           string
	IsNumericOverflow bool
}

func (DecodeError) Error

func (e DecodeError) Error() string

type EncodeError

type EncodeError struct {
	Message string
}

func (EncodeError) Error

func (e EncodeError) Error() string

Jump to

Keyboard shortcuts

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