table

package
v2.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

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

Column represents a database column with type safety

func Col

func Col[T any](name string) *Column[T]

Col is a shorthand for NewColumn

func NewColumn

func NewColumn[T any](name string) *Column[T]

NewColumn creates a new column

func (*Column[T]) AutoIncrement

func (c *Column[T]) AutoIncrement() *Column[T]

AutoIncrement marks this column as auto-incrementing

func (*Column[T]) Default

func (c *Column[T]) Default(val T) *Column[T]

Default sets a default value for this column

func (*Column[T]) ForeignKey

func (c *Column[T]) ForeignKey(table, column string) *Column[T]

ForeignKey sets a foreign key reference

func (*Column[T]) FullName

func (c *Column[T]) FullName() string

FullName returns the fully qualified column name (table.column)

func (*Column[T]) Name

func (c *Column[T]) Name() string

Name returns the column name

func (*Column[T]) NotNull

func (c *Column[T]) NotNull() *Column[T]

NotNull marks this column as NOT NULL

func (*Column[T]) Options

func (c *Column[T]) Options() ColumnOptions

Options returns the column options

func (*Column[T]) PrimaryKey

func (c *Column[T]) PrimaryKey() *Column[T]

PrimaryKey marks this column as a primary key

func (*Column[T]) SQLString added in v2.0.9

func (c *Column[T]) SQLString() (string, bool)

SQLString implements the SQLValue interface for Column Returns the column name and false (not a literal value)

func (*Column[T]) TableName

func (c *Column[T]) TableName() string

TableName returns the table name this column belongs to

func (*Column[T]) Unique

func (c *Column[T]) Unique() *Column[T]

Unique marks this column as UNIQUE

func (*Column[T]) Value added in v2.0.9

func (c *Column[T]) Value() interface{}

Value implements the SQLValue interface for Column Returns nil because columns don't have literal values

type ColumnOptions

type ColumnOptions struct {
	PrimaryKey bool
	NotNull    bool
	Unique     bool
	AutoIncr   bool
	DefaultVal interface{}
	ForeignKey *ForeignKeyRef
}

ColumnOptions holds column metadata

type ColumnRef

type ColumnRef struct {
	Name     string
	FullName string
	Type     reflect.Type
	Options  ColumnOptions
}

ColumnRef holds metadata about a column without type parameters

type ForeignKeyRef

type ForeignKeyRef struct {
	Table  string
	Column string
}

ForeignKeyRef represents a foreign key relationship

type Table

type Table[T any] struct {
	C T // Column accessor (holds column definitions)
	// contains filtered or unexported fields
}

Table represents a database table with typed columns

func NewTable

func NewTable[T any](name string, columnStruct T) *Table[T]

NewTable creates a new table with the given name and column definitions

func (*Table[T]) ColumnNames

func (t *Table[T]) ColumnNames() []string

ColumnNames returns all column names

func (*Table[T]) Columns

func (t *Table[T]) Columns() []*ColumnRef

Columns returns all column references

func (*Table[T]) Name

func (t *Table[T]) Name() string

Name returns the table name

type TableInterface added in v2.0.7

type TableInterface interface {
	Name() string
	Columns() []*ColumnRef
}

TableInterface is the interface that all table types must implement. It provides the table name for use in SQL queries.

Jump to

Keyboard shortcuts

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