sqldav

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 12 Imported by: 2

README

sqldav

Go Reference GitHub go.mod Go version (subdirectory of monorepo) GitHub release (latest by date) codecov Go Report Card GitHub License

"sql.Scanner"/"driver.Valuer" for DynamoDB PartiQL (And its Tooltip)

Types

sqldav implements the following sql.Scanner, driver.Valuer

  • sqldav.Set[string | int | float64 | []byte], the Defined Type of []string, []int, []float64, [][]byte. Converted to set in DynamoDB.

  • sqldav.List, the Defined Type of []interface{}. Converted to list in DynamoDB.

  • sqldav.Map, the Defined Type of map[string]interface{}. Converted to map in DynamoDB.

  • sqldav.TypedList[T], the Defined Type of []T. Converted to list in DynamoDB.

Contributing

Feel free to open a PR or an Issue.

However, you must promise to follow our Code of Conduct.

License

sqldav released under the MIT License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrValueIsIncompatibleOfStringSlice  = errors.New("value is incompatible of string slice")
	ErrValueIsIncompatibleOfIntSlice     = errors.New("value is incompatible of int slice")
	ErrValueIsIncompatibleOfFloat64Slice = errors.New("value is incompatible of float64 slice")
	ErrValueIsIncompatibleOfBinarySlice  = errors.New("value is incompatible of []byte slice")
	ErrCollectionAlreadyContainsItem     = errors.New("collection already contains item")
	ErrFailedToCast                      = errors.New("failed to cast")
)
View Source
var ErrDocumentAttributeValueIsIncompatible = fmt.Errorf("document-attribute-value is incompatible")

ErrDocumentAttributeValueIsIncompatible occurs when an incompatible conversion to following:

  • *types.AttributeValueMemberL
  • *types.AttributeValueMemberM
  • *types.AttributeValueMemberSS
  • *types.AttributeValueMemberNS
  • *types.AttributeValueMemberBS
View Source
var ErrNestedStructHasIncompatibleAttributes = errors.New("nested struct has incompatible attributes")

ErrNestedStructHasIncompatibleAttributes occurs when the nested struct has incompatible attributes.

Functions

func AssignMapValueToReflectValue

func AssignMapValueToReflectValue(rt reflect.Type, rv reflect.Value, mv map[string]interface{}) error

AssignMapValueToReflectValue assigns the map type value to the reflect.Value

func ToDocumentAttributeValue

func ToDocumentAttributeValue[T DocumentAttributeMember](value interface{}) (T, error)

ToDocumentAttributeValue converts given interface to a DocumentAttributeMember.

NOTE: this function returns a typed-nil if the conversion is incompatible. therefore, nil-check is not guaranteed to work.

Types

type DocumentAttributeMember

DocumentAttributeMember represents Document Attribute Member.

type List

type List []interface{}

List is a DynamoDB list type.

See: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html

func (*List) GormDataType added in v0.2.0

func (l *List) GormDataType() string

GormDataType returns the data type for Gorm.

func (*List) Scan

func (l *List) Scan(value interface{}) error

Scan implements the sql.Scanner#Scan

func (List) Value

func (l List) Value() (v driver.Value, err error)

Value implements the driver.Valuer interface.

type Map

type Map map[string]interface{}

Map is a DynamoDB map type.

See: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html

func (Map) GormDataType added in v0.2.0

func (m Map) GormDataType() string

GormDataType returns the data type for Gorm.

func (*Map) Scan

func (m *Map) Scan(value interface{}) error

Scan implements the sql.Scanner#Scan

func (Map) Value

func (m Map) Value() (v driver.Value, err error)

Value implements the driver.Valuer interface.

type Set

type Set[T SetSupportable] []T

Set is a DynamoDB set type.

See: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html

func (*Set[T]) GormDataType added in v0.2.0

func (s *Set[T]) GormDataType() string

GormDataType returns the data type for Gorm.

func (*Set[T]) Scan

func (s *Set[T]) Scan(value interface{}) error

Scan implements the sql.Scanner#Scan

func (Set[T]) Value

func (s Set[T]) Value() (v driver.Value, err error)

type SetSupportable

type SetSupportable interface {
	string | []byte | int | float64
}

SetSupportable are the types that support the Set

type TypedList

type TypedList[T any] []T

TypedList is a DynamoDB list type with type specification.

See: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html

func (*TypedList[T]) GormDataType added in v0.2.0

func (l *TypedList[T]) GormDataType() string

GormDataType returns the data type for Gorm.

func (*TypedList[T]) Scan

func (l *TypedList[T]) Scan(value interface{}) error

Scan implements the sql.Scanner#Scan

func (TypedList[T]) Value

func (l TypedList[T]) Value() (v driver.Value, err error)

Value implements the driver.Valuer interface.

Jump to

Keyboard shortcuts

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