dynamodb

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package dynamodb converts AWS SDK v2 DynamoDB attributes to Go values.

UnmarshalAttribute decodes one attribute and UnmarshalItem decodes an item. Number preserves large integers using math/big rather than silently losing precision. AttributeError reports unsupported attribute or number forms.

Module boundary

This optional SDK adapter delegates conversion policy to the dependency-free Commons package. UnmarshallDynamoDB accepts JSON-shaped wire attributes when SDK types are not available. This package does not fetch items or manage tables; use an application-owned SDK client for those operations.

For usage and compatibility details, see the user guide.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Number

func Number(value string) (any, error)

Number applies the shared safe-number and large-integer conversion.

func UnmarshalAttribute

func UnmarshalAttribute(input types.AttributeValue) (any, error)

UnmarshalAttribute uses the SDK's native binary/set decoding with shared numeric conversion.

func UnmarshalItem

func UnmarshalItem(input map[string]types.AttributeValue) (map[string]any, error)
Example
package main

import (
	"fmt"

	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
	"github.com/rambow-cloud/powertools-lambda-go/commons/dynamodb"
)

func main() {
	item, err := dynamodb.UnmarshalItem(map[string]types.AttributeValue{
		"name":  &types.AttributeValueMemberS{Value: "orders"},
		"count": &types.AttributeValueMemberN{Value: "3"},
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(item["name"], item["count"])
}
Output:
orders 3

func UnmarshallDynamoDB

func UnmarshallDynamoDB(input map[string]any) (map[string]any, error)

UnmarshallDynamoDB delegates raw AttributeValue conversion to dependency-free Commons.

Types

type AttributeError

type AttributeError = commons.DynamoDBAttributeError

AttributeError preserves the public error identity across raw and SDK adapters.

Jump to

Keyboard shortcuts

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