users

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserMeta = drel.ModelMeta[User]{
	Table:         "users",
	Columns:       []string{"id", "name", "balance", "created_at", "updated_at"},
	PKColumns:     []string{"id"},
	Scan:          scanUser,
	Snapshot:      snapshotUser,
	Diff:          diffUser,
	PKValue:       userPKValue,
	InsertColumns: userInsertColumns,
	ScanReturning: userScanReturning,
	ColumnValue:   userColumnValue,
	NormalizeKey:  userNormalizeKey,
}
View Source
var Users = struct {
	ID        drel.OrderedColumn[int]
	Name      drel.StringColumn
	Balance   drel.OrderedColumn[int]
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	ID:        drel.NewOrderedCol[int]("id"),
	Name:      drel.NewStringCol("name"),
	Balance:   drel.NewOrderedCol[int]("balance"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}

Functions

This section is empty.

Types

type BalanceTransferred

type BalanceTransferred struct {
	FromID int
	ToID   int
	Amount int
}

type TxUserRepository

type TxUserRepository struct {
	*drel.TxRepository[User]
}

func (*TxUserRepository) FindByID

func (r *TxUserRepository) FindByID(ctx context.Context, id int) (*User, error)

type User

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

func NewUser

func NewUser(name string, balance int) *User

func (*User) Balance

func (u *User) Balance() int

func (*User) Name

func (u *User) Name() string

func (*User) Transfer

func (u *User) Transfer(amount int, to *User) error

type UserRepository

type UserRepository struct {
	*drel.Repository[User]
}

func (*UserRepository) FindByID

func (r *UserRepository) FindByID(ctx context.Context, id int) (*User, error)

Jump to

Keyboard shortcuts

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