Documentation ¶
Overview ¶
Package ddbpath provides logic for building and parsing Dynamo document paths
Index ¶
- Variables
- func Register(nb NameBuilder, fields map[string]FieldInfo)
- func SelectMapValues(v map[string]types.AttributeValue, paths ...string) (res map[string]types.AttributeValue, err error)
- func SelectValues(v types.AttributeValue, paths ...string) (res map[string]types.AttributeValue, err error)
- func Validate(nb NameBuilder, paths ...string) error
- type AnyPath
- type ErrFieldNotAllowed
- type ErrIndexNotAllowed
- type ErrTypeNotRegistered
- type ErrUnknownField
- type FieldInfo
- type FieldKind
- type FieldMaskPath
- type ItemList
- type ItemMap
- type List
- type Map
- type NameBuilder
- type PathElement
- type Registry
- func (r Registry) FieldsOf(nb NameBuilder) (fi map[string]FieldInfo, ok bool)
- func (r Registry) Register(nb NameBuilder, fields map[string]FieldInfo)
- func (r Registry) Traverse(nb NameBuilder, p string) (fi FieldInfo, flds map[string]FieldInfo, err error)
- func (r Registry) Validate(nb NameBuilder, paths ...string) (err error)
- type ValuePath
Constants ¶
This section is empty.
Variables ¶
var NoInfo = FieldInfo{}
NoInfo is the FieldInfo zero value
Functions ¶
func Register ¶ added in v0.2.6
func Register(nb NameBuilder, fields map[string]FieldInfo)
Register a generated name building struct with the default registry. It panics if the type is already registered.
func SelectMapValues ¶ added in v0.2.3
func SelectMapValues(v map[string]types.AttributeValue, paths ...string) (res map[string]types.AttributeValue, err error)
SelectMapValues is a convenient wrapper around SelectValues for the common scenario of selecting from map of attribute values.
func SelectValues ¶
func SelectValues(v types.AttributeValue, paths ...string) (res map[string]types.AttributeValue, err error)
SelectValues will return a subset of a composite attribute value 'v' (maps or sets), specified by 'paths'. This is usefull when only part of a DynamoDB item is allowed or desired for an operation. For example when only the keys need to be selected, or a partial update is performed using a mask.
func Validate ¶ added in v0.2.5
func Validate(nb NameBuilder, paths ...string) error
Validate each path in 'paths' given the path naming struct 'nb' as the root message where the paths are started from agains the default registery.
Types ¶
type AnyPath ¶ added in v0.2.6
type AnyPath struct{ expression.NameBuilder }
AnyPath is registered to support path validation into anypb structs
func (AnyPath) TypeURL ¶ added in v0.2.6
func (p AnyPath) TypeURL() expression.NameBuilder
TypeURL appends the path of the type url
func (AnyPath) Value ¶ added in v0.2.6
func (p AnyPath) Value() expression.NameBuilder
Value appends the path of the value
func (AnyPath) WithDynamoNameBuilder ¶ added in v0.2.6
func (p AnyPath) WithDynamoNameBuilder(n expression.NameBuilder) AnyPath
WithDynamoNameBuilder allows generic types to overwrite the path
type ErrFieldNotAllowed ¶ added in v0.2.6
type ErrFieldNotAllowed struct {
// contains filtered or unexported fields
}
func (ErrFieldNotAllowed) Error ¶ added in v0.2.6
func (e ErrFieldNotAllowed) Error() string
type ErrIndexNotAllowed ¶ added in v0.2.6
type ErrIndexNotAllowed struct {
// contains filtered or unexported fields
}
func (ErrIndexNotAllowed) Error ¶ added in v0.2.6
func (e ErrIndexNotAllowed) Error() string
type ErrTypeNotRegistered ¶ added in v0.2.6
type ErrTypeNotRegistered struct {
// contains filtered or unexported fields
}
ErrTypeNotRegistered is returned when a type is not registered in the registry being used
func (ErrTypeNotRegistered) Error ¶ added in v0.2.6
func (e ErrTypeNotRegistered) Error() string
type ErrUnknownField ¶ added in v0.2.6
type ErrUnknownField struct {
// contains filtered or unexported fields
}
func (ErrUnknownField) Error ¶ added in v0.2.6
func (e ErrUnknownField) Error() string
type FieldInfo ¶ added in v0.2.5
type FieldInfo struct { Kind FieldKind // list, map, basic, any etc Message reflect.Type // field holds a non-basic type, or nil if its a basic type }
FieldInfo of a field on a message
type FieldMaskPath ¶ added in v0.2.6
type FieldMaskPath struct{ expression.NameBuilder }
FieldMaskPath is registered to support path validation of fieldmask
func (FieldMaskPath) Masks ¶ added in v0.2.6
func (p FieldMaskPath) Masks() List
Masks appends the path of the value
func (FieldMaskPath) WithDynamoNameBuilder ¶ added in v0.2.6
func (p FieldMaskPath) WithDynamoNameBuilder(n expression.NameBuilder) FieldMaskPath
WithDynamoNameBuilder allows generic types to overwrite the path
type ItemList ¶ added in v0.2.4
type ItemList[T interface { WithDynamoNameBuilder(expression.NameBuilder) T }] struct{ expression.NameBuilder }
ItemList is a list of nested items
type ItemMap ¶ added in v0.2.4
type ItemMap[T interface { WithDynamoNameBuilder(expression.NameBuilder) T }] struct{ expression.NameBuilder }
ItemMap is a list of nested items
type List ¶ added in v0.2.4
type List struct{ expression.NameBuilder }
List of basic type(s)
func (List) Index ¶ added in v0.2.4
func (p List) Index(i int) expression.NameBuilder
Index into a list of basic types
type Map ¶ added in v0.2.4
type Map struct{ expression.NameBuilder }
Map of basic type(s)
func (Map) Key ¶ added in v0.2.4
func (p Map) Key(k string) expression.NameBuilder
Key into a map of basic types
type NameBuilder ¶ added in v0.2.6
type NameBuilder interface {
AppendName(field expression.NameBuilder) expression.NameBuilder
}
NameBuilder inteface is implemented by generated name building structs
type PathElement ¶
PathElement describes a part of the path. It is either an numeric index into a list (or set) or it is a string key into the field.
func AppendParsePath ¶
func AppendParsePath(p string, r []PathElement) ([]PathElement, error)
AppendParsePath will parse path 'p' and append elements to 'r'. If 'r' is already allocated with enough space to hold all the parts of 'p' it will not allocate any additional memory on the heap.
func ParsePath ¶
func ParsePath(p string) ([]PathElement, error)
ParsePath will parse 'p' in its elements and return them.
type Registry ¶ added in v0.2.6
type Registry struct {
// contains filtered or unexported fields
}
Registry holds type information so validation of string paths can happen efficiently
func (Registry) FieldsOf ¶ added in v0.2.6
func (r Registry) FieldsOf(nb NameBuilder) (fi map[string]FieldInfo, ok bool)
FieldsOf returns field information of a name builder implementation
func (Registry) Register ¶ added in v0.2.6
func (r Registry) Register(nb NameBuilder, fields map[string]FieldInfo)
Register a name builder with the registry for efficient validation. It panics if the typ is already registered.
type ValuePath ¶ added in v0.2.6
type ValuePath struct{ expression.NameBuilder }
ValuePath is registered to support path validation into structpb's value fields. It has no fields but is special in that it will accept any path into it.
func (ValuePath) WithDynamoNameBuilder ¶ added in v0.2.6
func (p ValuePath) WithDynamoNameBuilder(n expression.NameBuilder) ValuePath
WithDynamoNameBuilder allows generic types to overwrite the path