Custom item marshaling
This release adds ItemMarshaler
and ItemUnmarshaler
, which are interfaces allowing for total control of item marshaling. This is useful for handling dynamic items whose structure depends on its content. Thanks to @luma for submitting this in PR #126!
// ItemMarshaler is the interface implemented by objects that
// can marshal themselves into an Item (a map of strings
// to AttributeValues).
type ItemMarshaler interface {
MarshalDynamoItem() (map[string]*dynamodb.AttributeValue, error)
}
// ItemUnmarshaler is the interface implemented by
// objects that can unmarshal an Item (a map of strings
//to AttributeValues) into themselves.
type ItemUnmarshaler interface {
UnmarshalDynamoItem(item map[string]*dynamodb.AttributeValue) error
}