modeled

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package modeled provides builder Table, Col, and Key variants parameterized by a concrete Model, so the compiler knows which model a fragment belongs to.

Why modeled scope

builder.Table, builder.Col, and builder.Key are model-agnostic: the same column name can belong to any table. modeled tells the compiler which Model owns a Table, Col, or Key.

e.g.

Table[User]: modeled table by User model.
TCol[User, uint64]: column from User model and its type is uint64.
Key[User]: index defined on User model.

Usage

  • M / CastT builds a scoped table from a model
  • CastC builds a model scoped column
  • CT builds a typed model scoped column
  • CastK builds a model scoped index

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Col

type Col[M Model] interface {
	ModelNewer[M]
	builder.Col

	// ComputedBy returns a copy with a computed expression.
	ComputedBy(frag.Fragment) Col[M]
}

Col is a builder.Col bound to model type M.

func CastC

func CastC[M Model](c builder.Col) Col[M]

CastC wraps a builder.Col as a model-scoped Col.

type ColIter

type ColIter[M Model] interface {
	builder.ColIter
	MCols() iter.Seq[Col[M]]
}

ColIter iterates model-scoped columns.

type Key

type Key[M Model] interface {
	ModelNewer[M]
	builder.Key
	ColIter[M]
}

Key is a builder.Key bound to model type M.

func CastK

func CastK[M Model](k builder.Key) Key[M]

CastK wraps a builder.Key as a model-scoped Key.

type KeyIter

type KeyIter[M Model] interface {
	MKeys() iter.Seq[Key[M]]
}

KeyIter iterates model-scoped keys.

type Model

type Model = internal.Model

Model is a table-backed struct type.

type ModelNewer

type ModelNewer[M Model] internal.ModelNewer[M]

ModelNewer constructs a model instance of type M.

type Newer

type Newer[M internal.Model] struct{}

Newer embeds Model() for scoped table / column / key wrappers.

func (*Newer[M]) Model

func (m *Newer[M]) Model() *M

Model returns a new zero value of M.

type OrderAddition

type OrderAddition[M Model] interface {
	builder.OrderAddition
}

OrderAddition is a model-scoped order clause (same as builder.OrderAddition).

type TCol

type TCol[M Model, T any] interface {
	ModelNewer[M]
	builder.TCol[T]

	// ComputedBy returns an untyped model-scoped column with a computed expression.
	ComputedBy(frag.Fragment) Col[M]
	// TypedComputedBy returns a typed model-scoped column with a computed expression.
	TypedComputedBy(frag.Fragment) TCol[M, T]
}

TCol is a typed builder.TCol bound to model type M and value type T.

func CT

func CT[M Model, T any](c builder.Col) TCol[M, T]

CT wraps a builder.Col as a typed model-scoped TCol.

type Table

type Table[M Model] interface {
	builder.Table
	ModelNewer[M]

	// MK picks a model-scoped key by name.
	MK(string) Key[M]

	ColIter[M]
	KeyIter[M]
}

Table is a builder.Table bound to model type M.

func CastT

func CastT[M Model](t builder.Table) Table[M]

CastT wraps a builder.Table as a model-scoped Table.

func M

func M[M Model]() Table[M]

M builds a Table scoped to model type M by scanning a zero value of M.

Jump to

Keyboard shortcuts

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