examples

package
v1.0.22 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package examples demonstrates DynamORM's embedded struct support

Package examples demonstrates list operations with DynamORM UpdateBuilder

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DemonstrateListOperations

func DemonstrateListOperations()

DemonstrateListOperations shows how to use list append/prepend operations

func ExampleEmbeddedStructs added in v1.0.20

func ExampleEmbeddedStructs()

ExampleEmbeddedStructs demonstrates how to use embedded structs with DynamORM

Types

type BaseModel added in v1.0.20

type BaseModel struct {
	// Primary composite keys
	PK string `dynamorm:"pk"`
	SK string `dynamorm:"sk"`

	// Global Secondary Indexes for access patterns
	GSI1PK string `dynamorm:"index:gsi1,pk"`
	GSI1SK string `dynamorm:"index:gsi1,sk"`
	GSI2PK string `dynamorm:"index:gsi2,pk"`
	GSI2SK string `dynamorm:"index:gsi2,sk"`

	// Common metadata
	Type      string    `dynamorm:"attr:type"`
	TenantID  string    `dynamorm:"attr:tenant_id"`
	CreatedAt time.Time `dynamorm:"created_at"`
	UpdatedAt time.Time `dynamorm:"updated_at"`
	Version   int       `dynamorm:"version"`
}

BaseModel represents common fields for a single-table design pattern This struct can be embedded in other models to share common fields

type EmbeddedCustomer added in v1.0.20

type EmbeddedCustomer struct {
	BaseModel // Embedded struct - all fields are inherited

	// Customer-specific fields
	ID    string `dynamorm:"attr:id"`
	Email string `dynamorm:"attr:email"`
	Name  string `dynamorm:"attr:name"`
	Phone string `dynamorm:"attr:phone"`
}

EmbeddedCustomer demonstrates embedding BaseModel for a customer entity

func (*EmbeddedCustomer) TableName added in v1.0.20

func (c *EmbeddedCustomer) TableName() string

TableName returns the DynamoDB table name

type EmbeddedOrder added in v1.0.20

type EmbeddedOrder struct {
	BaseModel // Embedded struct

	// Order-specific fields
	ID         string    `dynamorm:"attr:id"`
	CustomerID string    `dynamorm:"attr:customer_id"`
	Total      float64   `dynamorm:"attr:total"`
	Status     string    `dynamorm:"attr:status"`
	OrderedAt  time.Time `dynamorm:"attr:ordered_at"`
}

Order shows how to use embedded structs with relationships

func (*EmbeddedOrder) TableName added in v1.0.20

func (o *EmbeddedOrder) TableName() string

TableName returns the DynamoDB table name

type EmbeddedProduct added in v1.0.20

type EmbeddedProduct struct {
	BaseModel // Same embedded struct

	// Product-specific fields
	ID          string  `dynamorm:"attr:id"`
	Name        string  `dynamorm:"attr:name"`
	Description string  `dynamorm:"attr:description"`
	Price       float64 `dynamorm:"attr:price"`
	Stock       int     `dynamorm:"attr:stock"`
	CategoryID  string  `dynamorm:"attr:category_id"`
}

Product demonstrates the same pattern for a different entity type

func (*EmbeddedProduct) TableName added in v1.0.20

func (p *EmbeddedProduct) TableName() string

TableName returns the DynamoDB table name

type Product

type Product struct {
	ID          string `dynamorm:"pk"`
	Name        string
	Tags        []string
	Categories  []string
	Description string
}

Product represents a product with tags

Directories

Path Synopsis
blog
Package main demonstrates proper DynamORM initialization patterns to avoid nil pointer dereference errors
Package main demonstrates proper DynamORM initialization patterns to avoid nil pointer dereference errors
lambda/process command
lambda/query command

Jump to

Keyboard shortcuts

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