Skip to content

andrewnoruk/dynamodb-helpers

 
 

Repository files navigation

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

About

Attribute value encode/decode adapted from encoding/json

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%