accounts

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: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccountMeta = drel.ModelMeta[Account]{
	Table:         "accounts",
	Columns:       []string{"id", "owner", "balance_amount", "balance_currency", "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]
	Owner           drel.StringColumn
	BalanceAmount   drel.Column[any]
	BalanceCurrency drel.Column[any]
	CreatedAt       drel.TimeColumn
	UpdatedAt       drel.TimeColumn
}{
	ID:              drel.NewOrderedCol[int]("id"),
	Owner:           drel.NewStringCol("owner"),
	BalanceAmount:   drel.NewCol[any]("balance_amount"),
	BalanceCurrency: drel.NewCol[any]("balance_currency"),
	CreatedAt:       drel.NewTimeCol("created_at"),
	UpdatedAt:       drel.NewTimeCol("updated_at"),
}

Functions

This section is empty.

Types

type Account

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

func NewAccount

func NewAccount(owner string, balance Money) *Account

func (*Account) Balance

func (a *Account) Balance() Money

func (*Account) Owner

func (a *Account) Owner() string

func (*Account) SetBalance

func (a *Account) SetBalance(m Money)

type AccountRepository

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

func (*AccountRepository) FindByID

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

type Money

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

Money is a multi-column value object mapping to amount + currency. Sub-column values must be comparable primitives (int, string here) so the generated per-sub-column diff works.

func NewMoney

func NewMoney(amount int, currency string) Money

func (Money) Amount

func (m Money) Amount() int

func (Money) Currency

func (m Money) Currency() string

func (Money) DrelColumns

func (m Money) DrelColumns() []string

drel.MultiColumnMapper.

func (*Money) DrelScanMulti

func (m *Money) DrelScanMulti(v []any) error

func (Money) DrelValues

func (m Money) DrelValues() ([]any, error)

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