models

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TaskMeta = drel.ModelMeta[Task]{
	Table:         "tasks",
	Columns:       []string{"id", "title", "done", "priority", "created_at", "updated_at"},
	PKColumns:     []string{"id"},
	Scan:          scanTask,
	Snapshot:      snapshotTask,
	Diff:          diffTask,
	PKValue:       taskPKValue,
	InsertColumns: taskInsertColumns,
	ScanReturning: taskScanReturning,
	ColumnValue:   taskColumnValue,
	NormalizeKey:  taskNormalizeKey,
}
View Source
var Tasks = struct {
	ID        drel.OrderedColumn[int]
	Title     drel.StringColumn
	Done      drel.BoolColumn
	Priority  drel.OrderedColumn[int]
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	ID:        drel.NewOrderedCol[int]("id"),
	Title:     drel.NewStringCol("title"),
	Done:      drel.NewBoolCol("done"),
	Priority:  drel.NewOrderedCol[int]("priority"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}

Functions

This section is empty.

Types

type Task

type Task struct {
	drel.Model[int]
	Title    string `db:"title"`
	Done     bool   `db:"done"`
	Priority int    `db:"priority"`
}

func NewTask

func NewTask(title string, priority int) *Task

func (*Task) MarkDone

func (t *Task) MarkDone()

func (*Task) SetPriority

func (t *Task) SetPriority(p int)

type TaskRepository

type TaskRepository struct {
	*drel.Repository[Task]
}

func (*TaskRepository) FindByID

func (r *TaskRepository) FindByID(ctx context.Context, id int) (*Task, error)

type TxTaskRepository

type TxTaskRepository struct {
	*drel.TxRepository[Task]
}

func (*TxTaskRepository) FindByID

func (r *TxTaskRepository) FindByID(ctx context.Context, id int) (*Task, error)

Jump to

Keyboard shortcuts

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