item

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package item models DynamoDB items: the full AttributeValue type system (S, N, B, BOOL, NULL, M, L, SS, NS, BS) with DynamoDB's semantics — numbers are arbitrary-precision decimals compared numerically (never floats), sets reject duplicates, and item size follows the documented 400 KB accounting.

Index

Constants

View Source
const MaxItemSize = 400 << 10

MaxItemSize is DynamoDB's 400 KB item bound.

Variables

View Source
var Zero = Decimal{}

Zero is the zero Decimal.

Functions

func Compare

func Compare(a, b Decimal) int

Compare returns -1, 0, or 1 for a<b, a==b, a>b.

func Equal

func Equal(a, b Value) bool

Equal reports deep equality with DynamoDB semantics (numeric comparison for N/NS; set order irrelevant).

func ItemJSON

func ItemJSON(it Item) json.RawMessage

ItemJSON renders a stored item back to the wire form.

func Size

func Size(it Item) int

Size computes an item's size per DynamoDB's documented accounting: attribute-name lengths plus value sizes.

Types

type Decimal

type Decimal struct {
	// contains filtered or unexported fields
}

Decimal is a normalized arbitrary-precision decimal.

func Add

func Add(a, b Decimal) Decimal

Add returns a+b (used by ADD update actions and SET arithmetic).

func ParseDecimal

func ParseDecimal(s string) (Decimal, *awshttp.APIError)

ParseDecimal parses a DynamoDB wire number.

func Sub

func Sub(a, b Decimal) Decimal

Sub returns a-b.

func (Decimal) Digits

func (d Decimal) Digits() string

Digits exposes the significant digits (keyenc needs them).

func (Decimal) Exp

func (d Decimal) Exp() int

Exp exposes the normalized exponent (keyenc needs it).

func (Decimal) IsZero

func (d Decimal) IsZero() bool

IsZero reports whether d is zero.

func (Decimal) Neg

func (d Decimal) Neg() bool

Neg reports the sign (keyenc needs it).

func (Decimal) String

func (d Decimal) String() string

String renders the normalized decimal in plain notation where reasonable, scientific otherwise (matching how values survive round-trips acceptably).

type Item

type Item = map[string]Value

Item is a stored item: attribute name → value.

func ItemFromJSON

func ItemFromJSON(raw json.RawMessage) (Item, *awshttp.APIError)

ItemFromJSON decodes a wire item (map of AttributeValues).

type Type

type Type string

Type enumerates AttributeValue kinds by their wire tag.

const (
	TypeS    Type = "S"
	TypeN    Type = "N"
	TypeB    Type = "B"
	TypeBool Type = "BOOL"
	TypeNull Type = "NULL"
	TypeM    Type = "M"
	TypeL    Type = "L"
	TypeSS   Type = "SS"
	TypeNS   Type = "NS"
	TypeBS   Type = "BS"
)

type Value

type Value struct {
	Type Type
	S    string
	N    Decimal
	B    []byte
	Bool bool
	M    map[string]Value
	L    []Value
	SS   []string
	NS   []Decimal
	BS   [][]byte
}

Value is one AttributeValue.

func FromJSON

func FromJSON(raw json.RawMessage) (Value, *awshttp.APIError)

FromJSON decodes one wire-format AttributeValue: {"S":"x"}, {"N":"1.5"}, ...

func (Value) DebugString

func (v Value) DebugString() string

DebugString renders a compact human-readable form (admin/inspection).

func (Value) JSON

func (v Value) JSON() json.RawMessage

JSON renders the wire form of a value.

func (Value) TypeName

func (v Value) TypeName() string

TypeName renders the human-facing type name used in error messages.

Jump to

Keyboard shortcuts

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