models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuthorMeta = drel.ModelMeta[Author]{
	Table:         "authors",
	Columns:       []string{"id", "name", "created_at", "updated_at"},
	PKColumn:      "id",
	Scan:          scanAuthor,
	Snapshot:      snapshotAuthor,
	Diff:          diffAuthor,
	PKValue:       authorPKValue,
	InsertColumns: authorInsertColumns,
	ScanReturning: authorScanReturning,
	ColumnValue:   authorColumnValue,
}
View Source
var AuthorProfileMeta = drel.ModelMeta[AuthorProfile]{
	Table:         "author_profiles",
	Columns:       []string{"id", "bio", "author_id", "created_at", "updated_at"},
	PKColumn:      "id",
	Scan:          scanAuthorprofile,
	Snapshot:      snapshotAuthorprofile,
	Diff:          diffAuthorprofile,
	PKValue:       authorprofilePKValue,
	InsertColumns: authorprofileInsertColumns,
	ScanReturning: authorprofileScanReturning,
	ColumnValue:   authorprofileColumnValue,
}
View Source
var AuthorProfiles = struct {
	ID        drel.OrderedColumn[int]
	Bio       drel.StringColumn
	AuthorID  drel.OrderedColumn[int]
	CreatedAt drel.Column[time.Time]
	UpdatedAt drel.Column[time.Time]
}{
	ID:        drel.NewOrderedCol[int]("id"),
	Bio:       drel.NewStringCol("bio"),
	AuthorID:  drel.NewOrderedCol[int]("author_id"),
	CreatedAt: drel.NewCol[time.Time]("created_at"),
	UpdatedAt: drel.NewCol[time.Time]("updated_at"),
}
View Source
var Authors = struct {
	ID        drel.OrderedColumn[int]
	Name      drel.StringColumn
	CreatedAt drel.Column[time.Time]
	UpdatedAt drel.Column[time.Time]
}{
	ID:        drel.NewOrderedCol[int]("id"),
	Name:      drel.NewStringCol("name"),
	CreatedAt: drel.NewCol[time.Time]("created_at"),
	UpdatedAt: drel.NewCol[time.Time]("updated_at"),
}
View Source
var BookMeta = drel.ModelMeta[Book]{
	Table:         "books",
	Columns:       []string{"id", "title", "author_id", "created_at", "updated_at"},
	PKColumn:      "id",
	Scan:          scanBook,
	Snapshot:      snapshotBook,
	Diff:          diffBook,
	PKValue:       bookPKValue,
	InsertColumns: bookInsertColumns,
	ScanReturning: bookScanReturning,
	ColumnValue:   bookColumnValue,
}
View Source
var Books = struct {
	ID        drel.OrderedColumn[int]
	Title     drel.StringColumn
	AuthorID  drel.OrderedColumn[int]
	CreatedAt drel.Column[time.Time]
	UpdatedAt drel.Column[time.Time]
}{
	ID:        drel.NewOrderedCol[int]("id"),
	Title:     drel.NewStringCol("title"),
	AuthorID:  drel.NewOrderedCol[int]("author_id"),
	CreatedAt: drel.NewCol[time.Time]("created_at"),
	UpdatedAt: drel.NewCol[time.Time]("updated_at"),
}

Functions

This section is empty.

Types

type Author

type Author struct {
	drel.Model[int]
	Name    string         `db:"name"`
	Books   []*Book        `rel:"has_many,fk=author_id"`
	Profile *AuthorProfile `rel:"has_one,fk=author_id"`
}

type AuthorProfile

type AuthorProfile struct {
	drel.Model[int]
	Bio      string `db:"bio"`
	AuthorID int    `db:"author_id"`
}

type AuthorProfileRepository

type AuthorProfileRepository struct {
	*drel.Repository[AuthorProfile]
}

func (*AuthorProfileRepository) FindByID

func (r *AuthorProfileRepository) FindByID(ctx context.Context, id int) (*AuthorProfile, error)

type AuthorRepository

type AuthorRepository struct {
	*drel.Repository[Author]
}

func (*AuthorRepository) FindByID

func (r *AuthorRepository) FindByID(ctx context.Context, id int) (*Author, error)

type Book

type Book struct {
	drel.Model[int]
	Title    string  `db:"title"`
	AuthorID int     `db:"author_id"`
	Author   *Author `rel:"belongs_to,fk=author_id"`
}

type BookRepository

type BookRepository struct {
	*drel.Repository[Book]
}

func (*BookRepository) FindByID

func (r *BookRepository) FindByID(ctx context.Context, id int) (*Book, error)

type TxAuthorProfileRepository

type TxAuthorProfileRepository struct {
	*drel.TxRepository[AuthorProfile]
}

func (*TxAuthorProfileRepository) FindByID

type TxAuthorRepository

type TxAuthorRepository struct {
	*drel.TxRepository[Author]
}

func (*TxAuthorRepository) FindByID

func (r *TxAuthorRepository) FindByID(ctx context.Context, id int) (*Author, error)

type TxBookRepository

type TxBookRepository struct {
	*drel.TxRepository[Book]
}

func (*TxBookRepository) FindByID

func (r *TxBookRepository) FindByID(ctx context.Context, id int) (*Book, error)

Jump to

Keyboard shortcuts

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