Documentation
ΒΆ
Overview ΒΆ
Package examples demonstrates TableTheory's embedded struct support
Package examples contains focused snippets for new TableTheory capabilities.
Package examples demonstrates list operations with TableTheory UpdateBuilder
Index ΒΆ
- func DemonstrateConditionalHelpers(db core.ExtendedDB) error
- func DemonstrateListOperations(db core.ExtendedDB) error
- func DemonstrateTransactionBuilder(db core.ExtendedDB) error
- func ExampleEmbeddedStructs(db core.ExtendedDB) error
- func FaceTheoryFreshUntilUnix(meta FaceTheoryCacheMetadata) int64
- func FaceTheoryIsFresh(meta FaceTheoryCacheMetadata, now time.Time) bool
- func FaceTheoryTTLUnix(generatedAt int64, retention time.Duration) int64
- type BaseModel
- type Bookmark
- type BookmarkAudit
- type BookmarkQuota
- type EmbeddedCustomer
- type EmbeddedOrder
- type EmbeddedProduct
- type FaceTheoryCacheMetadata
- type Invoice
- type Product
- type Session
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func DemonstrateConditionalHelpers ΒΆ
func DemonstrateConditionalHelpers(db core.ExtendedDB) error
DemonstrateConditionalHelpers shows insert-only creates, optimistic updates, and guarded deletes.
func DemonstrateListOperations ΒΆ
func DemonstrateListOperations(db core.ExtendedDB) error
DemonstrateListOperations shows how to use list append/prepend operations against an existing product row.
func DemonstrateTransactionBuilder ΒΆ
func DemonstrateTransactionBuilder(db core.ExtendedDB) error
DemonstrateTransactionBuilder composes a dual-write with quota checks.
func ExampleEmbeddedStructs ΒΆ
func ExampleEmbeddedStructs(db core.ExtendedDB) error
ExampleEmbeddedStructs demonstrates how to use embedded structs with TableTheory. The caller provides an initialized DB whose table already exists; the driver in examples/drivers creates it with the gsi1 and gsi2 indexes.
func FaceTheoryFreshUntilUnix ΒΆ
func FaceTheoryFreshUntilUnix(meta FaceTheoryCacheMetadata) int64
FaceTheoryFreshUntilUnix returns the freshness boundary for ISR (not DynamoDB TTL).
func FaceTheoryIsFresh ΒΆ
func FaceTheoryIsFresh(meta FaceTheoryCacheMetadata, now time.Time) bool
FaceTheoryIsFresh reports whether the metadata is within its ISR freshness window.
Types ΒΆ
type BaseModel ΒΆ
type BaseModel struct {
CreatedAt time.Time `theorydb:"created_at"`
UpdatedAt time.Time `theorydb:"updated_at"`
PK string `theorydb:"pk"`
SK string `theorydb:"sk"`
GSI1PK string `theorydb:"index:gsi1,pk"`
GSI1SK string `theorydb:"index:gsi1,sk"`
GSI2PK string `theorydb:"index:gsi2,pk"`
GSI2SK string `theorydb:"index:gsi2,sk"`
Type string `theorydb:"attr:type"`
TenantID string `theorydb:"attr:tenantId"`
Version int `theorydb:"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 ΒΆ
type Bookmark struct {
Created time.Time `json:"created_at"`
PK string `theorydb:"pk" json:"pk"`
SK string `theorydb:"sk" json:"sk"`
UserID string `json:"user_id"`
URL string `json:"url"`
Category string `json:"category"`
}
Bookmark models a bookmark stored in a single-table design.
type BookmarkAudit ΒΆ
type BookmarkAudit struct {
CreatedAt time.Time `json:"created_at"`
PK string `theorydb:"pk" json:"pk"`
SK string `theorydb:"sk" json:"sk"`
Action string `json:"action"`
ActorID string `json:"actor_id"`
}
BookmarkAudit is written alongside bookmark mutations.
func (BookmarkAudit) TableName ΒΆ added in v6.2.0
func (BookmarkAudit) TableName() string
TableName keeps this example's table distinct when examples share one local DynamoDB instance.
type BookmarkQuota ΒΆ
type BookmarkQuota struct {
PK string `theorydb:"pk" json:"pk"`
SK string `theorydb:"sk" json:"sk"`
Remaining int `json:"remaining"`
}
BookmarkQuota tracks how many writes a user can make in a window.
func (BookmarkQuota) TableName ΒΆ added in v6.2.0
func (BookmarkQuota) TableName() string
TableName keeps this example's table distinct when examples share one local DynamoDB instance.
type EmbeddedCustomer ΒΆ
type EmbeddedCustomer struct {
ID string `theorydb:"attr:id"`
Email string `theorydb:"attr:email"`
Name string `theorydb:"attr:name"`
Phone string `theorydb:"attr:phone"`
BaseModel
}
EmbeddedCustomer demonstrates embedding BaseModel for a customer entity
func (*EmbeddedCustomer) TableName ΒΆ
func (c *EmbeddedCustomer) TableName() string
TableName returns the DynamoDB table name
type EmbeddedOrder ΒΆ
type EmbeddedOrder struct {
OrderedAt time.Time `theorydb:"attr:orderedAt"`
ID string `theorydb:"attr:id"`
CustomerID string `theorydb:"attr:customerId"`
Status string `theorydb:"attr:status"`
BaseModel
Total float64 `theorydb:"attr:total"`
}
EmbeddedOrder shows how to use embedded structs with relationships
func (*EmbeddedOrder) TableName ΒΆ
func (o *EmbeddedOrder) TableName() string
TableName returns the DynamoDB table name
type EmbeddedProduct ΒΆ
type EmbeddedProduct struct {
ID string `theorydb:"attr:id"`
Name string `theorydb:"attr:name"`
Description string `theorydb:"attr:description"`
CategoryID string `theorydb:"attr:categoryId"`
BaseModel
Price float64 `theorydb:"attr:price"`
Stock int `theorydb:"attr:stock"`
}
EmbeddedProduct demonstrates the same pattern for a different entity type
func (*EmbeddedProduct) TableName ΒΆ
func (p *EmbeddedProduct) TableName() string
TableName returns the DynamoDB table name
type FaceTheoryCacheMetadata ΒΆ
type FaceTheoryCacheMetadata struct {
PK string `theorydb:"pk,attr:pk" json:"pk"`
SK string `theorydb:"sk,attr:sk" json:"sk"`
S3Key string `theorydb:"attr:s3_key" json:"s3_key"`
GeneratedAt int64 `theorydb:"attr:generated_at" json:"generated_at"`
RevalidateSeconds int64 `theorydb:"attr:revalidate_seconds" json:"revalidate_seconds"`
ETag string `theorydb:"attr:etag,omitempty" json:"etag,omitempty"`
TTL int64 `theorydb:"ttl,attr:ttl,omitempty" json:"ttl,omitempty"`
// contains filtered or unexported fields
}
FaceTheoryCacheMetadata is a minimal metadata row shape for ISR cache tables.
See: docs/facetheory/isr-cache-schema.md
func (FaceTheoryCacheMetadata) TableName ΒΆ
func (FaceTheoryCacheMetadata) TableName() string
type Invoice ΒΆ
type Invoice struct {
PK string `theorydb:"pk" json:"pk"`
SK string `theorydb:"sk" json:"sk"`
Status string `json:"status"`
Total int64 `json:"total"`
Balance int64 `json:"balance"`
}
Invoice is used for batch retrieval demos.
func DemonstrateBatchGetBuilder ΒΆ
func DemonstrateBatchGetBuilder(db core.ExtendedDB) ([]Invoice, error)
DemonstrateBatchGetBuilder fetches invoices with chunking, retries, and callbacks.
type Product ΒΆ
type Product struct {
ID string `theorydb:"pk"`
Name string
Description string `theorydb:"omitempty"`
Tags []string
Categories []string
Labels []string `theorydb:"set"`
ViewCount int
}
Product represents a product with list and set attributes.
Source Files
ΒΆ
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
cdk-multilang
|
|
|
lambdas/go
command
|
|
|
local/go
command
Command local-writer writes the shared cdk-multilang DemoItem to a local DynamoDB and KMS (no AWS account).
|
Command local-writer writes the shared cdk-multilang DemoItem to a local DynamoDB and KMS (no AWS account). |
|
Package main drives the loose examples/*.go snippets against DynamoDB Local.
|
Package main drives the loose examples/*.go snippets against DynamoDB Local. |
|
Package main demonstrates proper TableTheory initialization patterns to avoid nil pointer dereference errors
|
Package main demonstrates proper TableTheory initialization patterns to avoid nil pointer dereference errors |
|
lambda/process
command
|
|
|
lambda/query
command
|
|
|
lambda/reconcile
command
|
|
|
Package main drives the typed generic API against DynamoDB Local.
|
Package main drives the typed generic API against DynamoDB Local. |