Documentation
¶
Overview ¶
Package examples demonstrates DynamORM's embedded struct support
Package examples contains focused snippets for new DynamORM capabilities.
Package examples demonstrates list operations with DynamORM UpdateBuilder
Index ¶
- func DemonstrateBatchGetBuilder()
- func DemonstrateConditionalHelpers()
- func DemonstrateListOperations()
- func DemonstrateTransactionBuilder()
- func ExampleEmbeddedStructs()
- type BaseModel
- type Bookmark
- type BookmarkAudit
- type BookmarkQuota
- type EmbeddedCustomer
- type EmbeddedOrder
- type EmbeddedProduct
- type Invoice
- type Product
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DemonstrateBatchGetBuilder ¶ added in v1.0.37
func DemonstrateBatchGetBuilder()
DemonstrateBatchGetBuilder fetches invoices with chunking, retries, and callbacks.
func DemonstrateConditionalHelpers ¶ added in v1.0.37
func DemonstrateConditionalHelpers()
DemonstrateConditionalHelpers shows insert-only creates, optimistic updates, and guarded deletes.
func DemonstrateListOperations ¶
func DemonstrateListOperations()
DemonstrateListOperations shows how to use list append/prepend operations
func DemonstrateTransactionBuilder ¶ added in v1.0.37
func DemonstrateTransactionBuilder()
DemonstrateTransactionBuilder composes a dual-write with quota checks.
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:tenantId"`
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 Bookmark ¶ added in v1.0.37
type Bookmark struct {
PK string `dynamorm:"pk" json:"pk"`
SK string `dynamorm:"sk" json:"sk"`
UserID string `json:"user_id"`
URL string `json:"url"`
Category string `json:"category"`
Created time.Time `json:"created_at"`
}
Bookmark models a bookmark stored in a single-table design.
type BookmarkAudit ¶ added in v1.0.37
type BookmarkAudit struct {
PK string `dynamorm:"pk" json:"pk"`
SK string `dynamorm:"sk" json:"sk"`
Action string `json:"action"`
ActorID string `json:"actor_id"`
CreatedAt time.Time `json:"created_at"`
}
BookmarkAudit is written alongside bookmark mutations.
type BookmarkQuota ¶ added in v1.0.37
type BookmarkQuota struct {
PK string `dynamorm:"pk" json:"pk"`
SK string `dynamorm:"sk" json:"sk"`
Remaining int `json:"remaining"`
}
BookmarkQuota tracks how many writes a user can make in a window.
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:customerId"`
Total float64 `dynamorm:"attr:total"`
Status string `dynamorm:"attr:status"`
OrderedAt time.Time `dynamorm:"attr:orderedAt"`
}
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:categoryId"`
}
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 Invoice ¶ added in v1.0.37
type Invoice struct {
PK string `dynamorm:"pk" json:"pk"`
SK string `dynamorm:"sk" json:"sk"`
Status string `json:"status"`
Total int64 `json:"total"`
Balance int64 `json:"balance"`
}
Invoice is used for batch retrieval demos.
Source Files
¶
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
|
|
|
lambda/reconcile
command
|
|