ddbconv

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package ddbconv can be used to convert between dynamodb.AttributeValue and the Go type system Some of these functions provide little more than improved readability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBinary

func DecodeBinary(attr dynamodb.AttributeValue) []byte

DecodeBinary converts an AttributeValue into a []byte, which will be empty if the value is not a Binary (B).

func DecodeBinarySet

func DecodeBinarySet(attr dynamodb.AttributeValue) [][]byte

DecodeBinarySet converts an AttributeValue into a [][]byte, which will be empty if the value is not a BinarySet (BS).

func DecodeBool

func DecodeBool(attr dynamodb.AttributeValue) bool

DecodeBool converts an AttributeValue into a bool, and will panic if the value is not a Boolean (BOOL).

func DecodeInt

func DecodeInt(av dynamodb.AttributeValue) int

DecodeInt converts an AttributeValue into an int, and will panic if the value is not an integral Number, if it is a NULL, or if it will not fit in an int without losing precision.

func DecodeIntSet

func DecodeIntSet(attr dynamodb.AttributeValue) []int

DecodeIntSet converts an AttributeValue into an []int, which will be empty if the value is not a NumberSet (NS), or if any value in the set is not an integral number that will fit in an int.

func DecodeList

DecodeList converts an AttributeValue into a []AttributeValue, which will be empty if the value is not a List (L).

func DecodeMap

DecodeMap converts an AttributeValue into a map[string]AttributeValue, which will be empty if the value is not a Map (M).

func DecodeNumber

DecodeNumber converts an AttributeValue into a Number, and will panic if the value is not a Number (N), or if the value is a NULL.

func DecodeString

func DecodeString(attr dynamodb.AttributeValue) string

DecodeString converts an AttributeValue into a String, which will be empty if the value if not a String (S).

func DecodeStringSet

func DecodeStringSet(attr dynamodb.AttributeValue) []string

DecodeStringSet converts an AttributeValue into a []string, which will be empty if the value is not a StringSet (SS).

func EncodeBinary

func EncodeBinary(val []byte) dynamodb.AttributeValue

EncodeBinary converts a []byte into an AttributeValue with the Binary (B) type.

func EncodeBinarySet

func EncodeBinarySet(val [][]byte) dynamodb.AttributeValue

EncodeBinarySet converts a [][]byte into an AttributeValue with the BinarySet (BS) type.

func EncodeBool

func EncodeBool(val bool) dynamodb.AttributeValue

EncodeBool converts a bool into an AttributeValue with the Boolean (BOOL) type.

func EncodeInt

func EncodeInt(val int) dynamodb.AttributeValue

EncodeInt converts an int into an AttributeValue with the Number (N) type.

func EncodeIntSet

func EncodeIntSet(vals []int) dynamodb.AttributeValue

EncodeIntSet converts an []int into an AttributeValue with the NumberSet (NS) type.

func EncodeList

EncodeList converts a []AttributeValue into an AttributeValue with the List (L) type.

func EncodeMap

EncodeMap converts a map[string]AttributeValue into an AttributeValue with the Map (M) type.

func EncodeNumber

EncodeNumber converts a Number into an AttributeValue with the Number (N) type.

func EncodeString

func EncodeString(val string) dynamodb.AttributeValue

EncodeString converts a string into an AttributeValue with the String (S) type.

func EncodeStringSet

func EncodeStringSet(val []string) dynamodb.AttributeValue

EncodeStringSet converts a []string into an AttributeValue with the StringSet (SS) type.

func FloatToNumber

func FloatToNumber(f float64) dynamodbattribute.Number

FloatToNumber converts a float64 into a Number.

func IntToNumber

func IntToNumber(i int) dynamodbattribute.Number

IntToNumber converts an int into a Number.

func IsNull

func IsNull(attr dynamodb.AttributeValue) bool

IsNull returns true if the given AttributeValue is a Null (NULL).

func TryDecodeBool

func TryDecodeBool(attr dynamodb.AttributeValue) (val, ok bool)

TryDecodeBool attempts to convert an AttributeValue into a bool. The ok result is true if the value is a Boolean (BOOL).

func TryDecodeInt

func TryDecodeInt(av dynamodb.AttributeValue) (int, bool)

TryDecodeInt attempts to convert an AttributeValue into an int. The boolean result is true if the decode was successful.

func TryDecodeNumber

func TryDecodeNumber(av dynamodb.AttributeValue) (result dynamodbattribute.Number, ok bool)

TryDecodeNumber attempts to convert and AttributeValue into a Number. The boolean result is true if the value is a Number (N).

func TryDecodeString

func TryDecodeString(attr dynamodb.AttributeValue) (result string, ok bool)

TryDecodeString attempts to convert an AttributeValue into a string. The ok result is true if the value is a String (S).

Types

This section is empty.

Jump to

Keyboard shortcuts

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