models

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccountMeta = drel.ModelMeta[Account]{
	Table:         "accounts",
	Columns:       []string{"id", "name", "role", "priority", "created_at", "updated_at"},
	PKColumns:     []string{"id"},
	Scan:          scanAccount,
	Snapshot:      snapshotAccount,
	Diff:          diffAccount,
	PKValue:       accountPKValue,
	InsertColumns: accountInsertColumns,
	ScanReturning: accountScanReturning,
	ColumnValue:   accountColumnValue,
	NormalizeKey:  accountNormalizeKey,
}
View Source
var Accounts = struct {
	ID        drel.OrderedColumn[int]
	Name      drel.StringColumn
	Role      drel.ComparableColumn[Role]
	Priority  drel.ComparableColumn[Priority]
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	ID:        drel.NewOrderedCol[int]("id"),
	Name:      drel.NewStringCol("name"),
	Role:      drel.NewComparableCol[Role]("role"),
	Priority:  drel.NewComparableCol[Priority]("priority"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}

Functions

This section is empty.

Types

type Account

type Account struct {
	drel.Model[int]
	Name     string   `db:"name"`
	Role     Role     `db:"role,default=user"`
	Priority Priority `db:"priority"`
}

type AccountRepository

type AccountRepository struct {
	*drel.Repository[Account]
}

func (*AccountRepository) FindByID

func (r *AccountRepository) FindByID(ctx context.Context, id int) (*Account, error)

type Priority

type Priority int
const (
	PriorityLow    Priority = 0
	PriorityMedium Priority = 1
	PriorityHigh   Priority = 2
)

func PriorityValues

func PriorityValues() []Priority

func (Priority) IsValid

func (r Priority) IsValid() bool

type Role

type Role string
const (
	RoleAdmin Role = "admin"
	RoleUser  Role = "user"
	RoleGuest Role = "guest"
)

func RoleValues

func RoleValues() []Role

func (Role) IsValid

func (r Role) IsValid() bool

type TxAccountRepository

type TxAccountRepository struct {
	*drel.TxRepository[Account]
}

func (*TxAccountRepository) FindByID

func (r *TxAccountRepository) FindByID(ctx context.Context, id int) (*Account, error)

Jump to

Keyboard shortcuts

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