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 NoteMeta = drel.ModelMeta[Note]{
	Table:         "notes",
	Columns:       []string{"id", "slug", "title", "category", "pinned", "created_at", "updated_at"},
	PKColumns:     []string{"id"},
	Scan:          scanNote,
	Snapshot:      snapshotNote,
	Diff:          diffNote,
	PKValue:       notePKValue,
	InsertColumns: noteInsertColumns,
	ScanReturning: noteScanReturning,
	ColumnValue:   noteColumnValue,
	NormalizeKey:  noteNormalizeKey,
}
View Source
var Notes = struct {
	ID        drel.OrderedColumn[int]
	Slug      drel.StringColumn
	Title     drel.StringColumn
	Category  drel.StringColumn
	Pinned    drel.BoolColumn
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	ID:        drel.NewOrderedCol[int]("id"),
	Slug:      drel.NewStringCol("slug"),
	Title:     drel.NewStringCol("title"),
	Category:  drel.NewStringCol("category"),
	Pinned:    drel.NewBoolCol("pinned"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}

Functions

This section is empty.

Types

type Note

type Note struct {
	drel.Model[int]
	Slug     string `db:"slug,unique"`
	Title    string `db:"title"`
	Category string `db:"category,index"`
	Pinned   bool   `db:"pinned"`
}

Note is a simple SQLite-backed model. The db tag options declare an index on `category` and a unique index on `slug`, which codegen turns into CREATE INDEX DDL in the generated migration.

func NewNote

func NewNote(slug, title, category string) *Note

func (*Note) Pin

func (n *Note) Pin()

func (*Note) Unpin

func (n *Note) Unpin()

type NoteRepository

type NoteRepository struct {
	*drel.Repository[Note]
}

func (*NoteRepository) FindByID

func (r *NoteRepository) FindByID(ctx context.Context, id int) (*Note, error)

type TxNoteRepository

type TxNoteRepository struct {
	*drel.TxRepository[Note]
}

func (*TxNoteRepository) FindByID

func (r *TxNoteRepository) FindByID(ctx context.Context, id int) (*Note, error)

Jump to

Keyboard shortcuts

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