typed

package
v2.0.2-rc Latest Latest
Warning

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

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

Documentation

Overview

Package typed provides additive generic wrappers around the stable TableTheory core interfaces. The wrappers keep the existing runtime behavior while moving common result/destination shapes into Go's type system at call sites.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key[T any] struct {
	// contains filtered or unexported fields
}

Key is a primary-key value tied to a specific model type.

func NewKey

func NewKey[T any](partitionKey any, sortKey ...any) Key[T]

NewKey creates a model-typed key without requiring a Model handle.

func (Key[T]) Core

func (k Key[T]) Core() core.KeyPair

Core returns the underlying untyped TableTheory key pair for interoperability.

type Model

type Model[T any] struct {
	// contains filtered or unexported fields
}

Model is a generic handle for one TableTheory model type.

func ModelOf

func ModelOf[T any](db core.DB) Model[T]

ModelOf creates a generic handle for model type T from an existing TableTheory DB.

func (Model[T]) BatchGet

func (m Model[T]) BatchGet(keys []Key[T]) ([]T, error)

BatchGet retrieves multiple items by typed keys.

func (Model[T]) Create

func (m Model[T]) Create(item *T) error

Create inserts item using the existing TableTheory create semantics.

func (Model[T]) CreateOrUpdate

func (m Model[T]) CreateOrUpdate(item *T) error

CreateOrUpdate upserts item using the existing TableTheory create-or-update semantics.

func (Model[T]) Delete

func (m Model[T]) Delete(item *T) error

Delete deletes item using the existing TableTheory delete semantics.

func (Model[T]) DeleteKey

func (m Model[T]) DeleteKey(key Key[T]) error

DeleteKey deletes one item by typed key.

func (Model[T]) Get

func (m Model[T]) Get(key Key[T]) (T, error)

Get fetches one item by typed key. Missing items return ErrItemNotFound.

func (Model[T]) GetOrNil

func (m Model[T]) GetOrNil(key Key[T]) (*T, error)

GetOrNil fetches one item by typed key and returns nil when it is absent.

func (Model[T]) Item

func (m Model[T]) Item(item *T) Query[T]

Item returns a generic query builder bound to item for create/update/delete operations.

func (Model[T]) Key

func (m Model[T]) Key(partitionKey any, sortKey ...any) Key[T]

Key creates a model-typed key.

func (Model[T]) Query

func (m Model[T]) Query() Query[T]

Query returns a generic query builder using a zero-value model instance for metadata.

func (Model[T]) Update

func (m Model[T]) Update(item *T, fields ...string) error

Update updates item fields using the existing TableTheory update semantics.

type Query

type Query[T any] struct {
	// contains filtered or unexported fields
}

Query is a generic query builder for a TableTheory model type.

func (Query[T]) All

func (q Query[T]) All() ([]T, error)

All returns all matching items as []T.

func (Query[T]) Between

func (q Query[T]) Between(field string, lo any, hi any) Query[T]

Between adds a BETWEEN condition with a two-argument value shape.

func (Query[T]) Count

func (q Query[T]) Count() (int64, error)

Count returns the number of matching items without materializing them.

func (Query[T]) Create

func (q Query[T]) Create() error

Create inserts the query's bound item.

func (Query[T]) CreateOrUpdate

func (q Query[T]) CreateOrUpdate() error

CreateOrUpdate upserts the query's bound item.

func (Query[T]) Delete

func (q Query[T]) Delete() error

Delete deletes the query's bound item.

func (Query[T]) Filter

func (q Query[T]) Filter(field string, op query.Operator, value any) Query[T]

Filter adds a filter condition and preserves the generic query type.

func (Query[T]) First

func (q Query[T]) First() (T, error)

First returns the first matching item as T.

func (Query[T]) FirstOrNil

func (q Query[T]) FirstOrNil() (*T, error)

FirstOrNil returns the first matching item or nil when it is absent.

func (Query[T]) Index

func (q Query[T]) Index(indexName string) Query[T]

Index selects an index and preserves the generic query type.

func (Query[T]) Limit

func (q Query[T]) Limit(limit int) Query[T]

Limit sets a result limit and preserves the generic query type.

func (Query[T]) Untyped

func (q Query[T]) Untyped() core.Query

Untyped exposes the underlying core.Query for compatibility with APIs not yet wrapped by the generic layer.

func (Query[T]) Update

func (q Query[T]) Update(fields ...string) error

Update updates selected fields on the query's bound item.

func (Query[T]) Where

func (q Query[T]) Where(field string, op query.Operator, value any) Query[T]

Where adds a condition and preserves the generic query type.

Jump to

Keyboard shortcuts

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