models

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserAccountMeta = drel.ModelMeta[UserAccount]{
	Table:         "user_accounts",
	Columns:       []string{"id", "email", "balance", "created_at", "updated_at"},
	PKColumns:     []string{"id"},
	Scan:          scanUseraccount,
	Snapshot:      snapshotUseraccount,
	Diff:          diffUseraccount,
	PKValue:       useraccountPKValue,
	InsertColumns: useraccountInsertColumns,
	ScanReturning: useraccountScanReturning,
	ColumnValue:   useraccountColumnValue,
	NormalizeKey:  useraccountNormalizeKey,
}
View Source
var UserAccounts = struct {
	ID        drel.OrderedColumn[int]
	Email     drel.ComparableColumn[Email]
	Balance   drel.ComparableColumn[Cents]
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	ID:        drel.NewOrderedCol[int]("id"),
	Email:     drel.NewComparableCol[Email]("email"),
	Balance:   drel.NewComparableCol[Cents]("balance"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}

Functions

This section is empty.

Types

type Cents

type Cents struct {
	// contains filtered or unexported fields
}

Cents is an int64-backed single-column value object. It would silently get a TEXT column before the W2-G2 VOBaseType fix.

func NewCents

func NewCents(n int64) Cents

func (Cents) Int64

func (c Cents) Int64() int64

func (*Cents) Scan

func (c *Cents) Scan(src any) error

func (Cents) Value

func (c Cents) Value() (driver.Value, error)

type Email

type Email struct {
	// contains filtered or unexported fields
}

Email is a string-backed single-column value object (sql.Scanner + driver.Valuer).

func NewEmail

func NewEmail(s string) (Email, error)

func (Email) IsZero

func (e Email) IsZero() bool

func (*Email) Scan

func (e *Email) Scan(src any) error

func (Email) String

func (e Email) String() string

func (Email) Value

func (e Email) Value() (driver.Value, error)

type TxUserAccountRepository

type TxUserAccountRepository struct {
	*drel.TxRepository[UserAccount]
}

func (*TxUserAccountRepository) FindByID

func (r *TxUserAccountRepository) FindByID(ctx context.Context, id int) (*UserAccount, error)

type UserAccount

type UserAccount struct {
	drel.Model[int]
	// contains filtered or unexported fields
}

UserAccount demonstrates single-column value objects (Email, Cents). It was renamed from Account to avoid a duplicate DB field name with accounts.Account (which demonstrates multi-column VOs).

func NewUserAccount

func NewUserAccount(email Email, balance Cents) *UserAccount

func (*UserAccount) Balance

func (a *UserAccount) Balance() Cents

func (*UserAccount) Email

func (a *UserAccount) Email() Email

func (*UserAccount) SetBalance

func (a *UserAccount) SetBalance(c Cents)

type UserAccountRepository

type UserAccountRepository struct {
	*drel.Repository[UserAccount]
}

func (*UserAccountRepository) FindByID

func (r *UserAccountRepository) FindByID(ctx context.Context, id int) (*UserAccount, error)

Jump to

Keyboard shortcuts

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