ddbconv

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2018 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 ddb.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 ddb.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 ddb.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 ddb.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 ddb.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

func DecodeList(attr ddb.AttributeValue) []ddb.AttributeValue

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

func DecodeMap

func DecodeMap(attr ddb.AttributeValue) map[string]ddb.AttributeValue

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

func DecodeNumber

func DecodeNumber(av ddb.AttributeValue) ddbattr.Number

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 ddb.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 ddb.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) ddb.AttributeValue

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

func EncodeBinarySet

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

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

func EncodeBool

func EncodeBool(val bool) ddb.AttributeValue

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

func EncodeInt

func EncodeInt(val int) ddb.AttributeValue

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

func EncodeIntSet

func EncodeIntSet(vals []int) ddb.AttributeValue

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

func EncodeList

func EncodeList(val []ddb.AttributeValue) ddb.AttributeValue

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

func EncodeMap

func EncodeMap(val map[string]ddb.AttributeValue) ddb.AttributeValue

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

func EncodeNumber

func EncodeNumber(n ddbattr.Number) ddb.AttributeValue

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

func EncodeString

func EncodeString(val string) ddb.AttributeValue

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

func EncodeStringSet

func EncodeStringSet(val []string) ddb.AttributeValue

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

func FloatToNumber

func FloatToNumber(f float64) ddbattr.Number

FloatToNumber converts a float64 into a Number.

func IntToNumber

func IntToNumber(i int) ddbattr.Number

IntToNumber converts an int into a Number.

func IsNull

func IsNull(attr ddb.AttributeValue) bool

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

func TryDecodeBool

func TryDecodeBool(attr ddb.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 ddb.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 ddb.AttributeValue) (result ddbattr.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 ddb.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