Documentation ¶
Index ¶
- func Codec10[T dynamo.Thing, A, B, C, D, E, F, G, H, I, J any](a, b, c, d, e, f, g, h, i, j string) (CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], CodecOf[T, E], ...)
- func Codec2[T dynamo.Thing, A, B any](a, b string) (CodecOf[T, A], CodecOf[T, B])
- func Codec3[T dynamo.Thing, A, B, C any](a, b, c string) (CodecOf[T, A], CodecOf[T, B], CodecOf[T, C])
- func Codec4[T dynamo.Thing, A, B, C, D any](a, b, c, d string) (CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D])
- func Codec5[T dynamo.Thing, A, B, C, D, E any](a, b, c, d, e string) (CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], CodecOf[T, E])
- func Codec6[T dynamo.Thing, A, B, C, D, E, F any](a, b, c, d, e, f string) (CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], CodecOf[T, E], ...)
- func Codec7[T dynamo.Thing, A, B, C, D, E, F, G any](a, b, c, d, e, f, g string) (CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], CodecOf[T, E], ...)
- func Codec8[T dynamo.Thing, A, B, C, D, E, F, G, H any](a, b, c, d, e, f, g, h string) (CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], CodecOf[T, E], ...)
- func Codec9[T dynamo.Thing, A, B, C, D, E, F, G, H, I any](a, b, c, d, e, f, g, h, i string) (CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], CodecOf[T, E], ...)
- func Decode(av types.AttributeValue, val interface{}, coder ...Coder) (err error)
- func Encode(val interface{}, coder ...Coder) (types.AttributeValue, error)
- func Must[T dynamo.Thing](keyval dynamo.KeyVal[T], err error) dynamo.KeyVal[T]
- func New[T dynamo.Thing](connector string, service dynamo.DynamoDB, prefixes curie.Prefixes) (dynamo.KeyVal[T], error)
- type CodecOf
- type Coder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Codec10 ¶
func Codec10[T dynamo.Thing, A, B, C, D, E, F, G, H, I, J any](a, b, c, d, e, f, g, h, i, j string) ( CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], CodecOf[T, E], CodecOf[T, F], CodecOf[T, G], CodecOf[T, H], CodecOf[T, I], CodecOf[T, J], )
Codec10 builds Codec for 10 attributes
func Codec3 ¶
func Codec3[T dynamo.Thing, A, B, C any](a, b, c string) ( CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], )
Codec4 builds Codec for 4 attributes
func Codec4 ¶
func Codec4[T dynamo.Thing, A, B, C, D any](a, b, c, d string) ( CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], )
Codec4 builds Codec for 4 attributes
func Codec5 ¶
func Codec5[T dynamo.Thing, A, B, C, D, E any](a, b, c, d, e string) ( CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], CodecOf[T, E], )
Codec5 builds Codec for 5 attributes
func Codec6 ¶
func Codec6[T dynamo.Thing, A, B, C, D, E, F any](a, b, c, d, e, f string) ( CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], CodecOf[T, E], CodecOf[T, F], )
Codec6 builds Codec for 6 attributes
func Codec7 ¶
func Codec7[T dynamo.Thing, A, B, C, D, E, F, G any](a, b, c, d, e, f, g string) ( CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], CodecOf[T, E], CodecOf[T, F], CodecOf[T, G], )
Codec7 builds Codec for 7 attributes
func Codec8 ¶
func Codec8[T dynamo.Thing, A, B, C, D, E, F, G, H any](a, b, c, d, e, f, g, h string) ( CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], CodecOf[T, E], CodecOf[T, F], CodecOf[T, G], CodecOf[T, H], )
Codec8 builds Codec for 8 attributes
func Codec9 ¶
func Codec9[T dynamo.Thing, A, B, C, D, E, F, G, H, I any](a, b, c, d, e, f, g, h, i string) ( CodecOf[T, A], CodecOf[T, B], CodecOf[T, C], CodecOf[T, D], CodecOf[T, E], CodecOf[T, F], CodecOf[T, G], CodecOf[T, H], CodecOf[T, I], )
Codec9 builds Codec for 9 attributes
func Decode ¶
func Decode(av types.AttributeValue, val interface{}, coder ...Coder) (err error)
Decode is a helper function to decode core domain types from Dynamo DB format. The helper ensures compact URI de-serialization from DynamoDB schema.
type MyType struct { ID MyComplexType Name MyComplexType } var ID, Name = dynamo.Codec2[MyType, MyDynamoType, MyDynamoType]("ID", "Name") func (x *MyType) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error { type tStruct *MyType return dynamo.Decode(av, tStruct(x), ID.Decode((*MyDynamoType)(&x.ID)), Name.Decode((*MyDynamoType)(&x.Name)), ) }
func Encode ¶
func Encode(val interface{}, coder ...Coder) (types.AttributeValue, error)
Encode is a helper function to encode core domain types into struct. The helper ensures compact URI serialization into DynamoDB schema.
type MyType struct { ID MyComplexType Name MyComplexType } var ID, Name = dynamo.Codec2[MyType, MyDynamoType, MyDynamoType]("ID", "Name") func (x MyType) MarshalDynamoDBAttributeValue() (types.AttributeValue, error) { type tStruct MyType return dynamo.Encode(av, tStruct(x), ID.Encode(MyDynamoType(x.ID)), Name.Encode(MyDynamoType(x.Name)), ) }
Types ¶
type CodecOf ¶
CodecOf for struct fields, the type implement Encode/Decode primitives. Codec helps to implement semi-automated encoding/decoding algebraic data type into the format compatible with storage.
Let's consider scenario were application uses complex types that skips implementation of marshal/unmarshal protocols. Here the type MyComplexType needs to be casted to MyDynamoType that knows how to marshal/unmarshal the type.
type MyType struct { ID MyComplexType Name MyComplexType } var ID, Name = dynamo.Codec2[MyType, MyDynamoType, MyDynamoType]("ID", "Name") func (t MyType) MarshalDynamoDBAttributeValue() (*dynamodb.AttributeValue, error) { type tStruct MyType return dynamo.Encode(tStruct(p), ID.Encode(MyDynamoType(t.ID)), Name.Encode(MyDynamoType(t.Name)), ) }
type Coder ¶
type Coder func(map[string]types.AttributeValue) (map[string]types.AttributeValue, error)
Coder is a function, applies transformation of generic dynamodb AttributeValue