testmodels

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuditOrderLineMeta = drel.ModelMeta[AuditOrderLine]{
	Table:         "audit_order_lines",
	Columns:       []string{"order_id", "line_no", "qty", "created_by", "updated_by", "created_at", "updated_at"},
	PKColumns:     []string{"order_id", "line_no"},
	Scan:          scanAuditorderline,
	Snapshot:      snapshotAuditorderline,
	Diff:          diffAuditorderline,
	PKValue:       auditorderlinePKValue,
	KeyValues:     auditorderlineKeyValues,
	InsertColumns: auditorderlineInsertColumns,
	ScanReturning: auditorderlineScanReturning,
	ColumnValue:   auditorderlineColumnValue,
	NormalizeKey:  auditorderlineNormalizeKey,
	KeyStrategy:   drel.KeyAppAssigned,
	SetKey:        func(p *AuditOrderLine, key any) { p.SetID(key.(OrderLineKey)) },
	KeyIsZero:     auditorderlineKeyIsZero,
	ScanGenerated: auditorderlineScanGenerated,
	HasAudit:      true,
	AuditSetCreate: func(p *AuditOrderLine, actor string) {
		createdByPtr, updatedByPtr := p.AuditPtrs()
		*createdByPtr = actor
		*updatedByPtr = actor
	},
	AuditSetUpdate: func(p *AuditOrderLine, actor string) {
		_, updatedByPtr := p.AuditPtrs()
		*updatedByPtr = actor
	},
}
View Source
var AuditOrderLines = struct {
	OrderID   drel.OrderedColumn[int]
	LineNo    drel.ComparableColumn[LineNo]
	Qty       drel.OrderedColumn[int]
	CreatedBy drel.StringColumn
	UpdatedBy drel.StringColumn
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	OrderID:   drel.NewOrderedCol[int]("order_id"),
	LineNo:    drel.NewComparableCol[LineNo]("line_no"),
	Qty:       drel.NewOrderedCol[int]("qty"),
	CreatedBy: drel.NewStringCol("created_by"),
	UpdatedBy: drel.NewStringCol("updated_by"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}
View Source
var AuditProductMeta = drel.ModelMeta[AuditProduct]{
	Table:     "a_products",
	Columns:   []string{"id", "name", "price", "created_by", "updated_by", "created_at", "updated_at"},
	PKColumns: []string{"id"},
	HasAudit:  true,
	AuditSetCreate: func(p *AuditProduct, actor string) {
		createdByPtr, updatedByPtr := p.AuditPtrs()
		*createdByPtr = actor
		*updatedByPtr = actor
	},
	AuditSetUpdate: func(p *AuditProduct, actor string) {
		_, updatedByPtr := p.AuditPtrs()
		*updatedByPtr = actor
	},
	Scan: func(row drel.Row) (*AuditProduct, error) {
		p := &AuditProduct{}
		idPtr, createdAtPtr, updatedAtPtr := p.ScanPtrs()
		createdByPtr, updatedByPtr := p.AuditPtrs()
		err := row.Scan(idPtr, &p.name, &p.price, createdByPtr, updatedByPtr, createdAtPtr, updatedAtPtr)
		if err != nil {
			return nil, err
		}
		return p, nil
	},
	Snapshot: func(p *AuditProduct) any {
		return apSnapshot{name: p.name, price: p.price}
	},
	Diff: func(p *AuditProduct, snap any) []drel.FieldChange {
		s := snap.(apSnapshot)
		var changes []drel.FieldChange
		if p.name != s.name {
			changes = append(changes, drel.FieldChange{Column: "name", Value: p.name})
		}
		if p.price != s.price {
			changes = append(changes, drel.FieldChange{Column: "price", Value: p.price})
		}
		return changes
	},
	PKValue: func(p *AuditProduct) any { return p.ID() },
	InsertColumns: func(p *AuditProduct) ([]string, []any) {
		return []string{"name", "price", "created_by", "updated_by"}, []any{p.name, p.price, p.CreatedBy(), p.UpdatedBy()}
	},
	ScanReturning: func(p *AuditProduct, row drel.Row) error {
		idPtr, createdAtPtr, updatedAtPtr := p.ScanPtrs()
		return row.Scan(idPtr, createdAtPtr, updatedAtPtr)
	},
}
View Source
var EventUserMeta = drel.ModelMeta[EventUser]{
	Table:     "event_users",
	Columns:   []string{"id", "name", "email", "created_at", "updated_at"},
	PKColumns: []string{"id"},
	Scan: func(row drel.Row) (*EventUser, error) {
		u := &EventUser{}
		idPtr, createdAtPtr, updatedAtPtr := u.ScanPtrs()
		err := row.Scan(idPtr, &u.name, &u.email, createdAtPtr, updatedAtPtr)
		if err != nil {
			return nil, err
		}
		return u, nil
	},
	Snapshot: func(u *EventUser) any {
		return eventUserSnapshot{name: u.name, email: u.email}
	},
	Diff: func(u *EventUser, snap any) []drel.FieldChange {
		s := snap.(eventUserSnapshot)
		var changes []drel.FieldChange
		if u.name != s.name {
			changes = append(changes, drel.FieldChange{Column: "name", Value: u.name})
		}
		if u.email != s.email {
			changes = append(changes, drel.FieldChange{Column: "email", Value: u.email})
		}
		return changes
	},
	PKValue: func(u *EventUser) any {
		return u.ID()
	},
	InsertColumns: func(u *EventUser) ([]string, []any) {
		return []string{"name", "email"}, []any{u.name, u.email}
	},
	ScanReturning: func(u *EventUser, row drel.Row) error {
		idPtr, createdAtPtr, updatedAtPtr := u.ScanPtrs()
		return row.Scan(idPtr, createdAtPtr, updatedAtPtr)
	},
}
View Source
var JSONDocMeta = drel.ModelMeta[JSONDoc]{
	Table:     "json_docs",
	Columns:   []string{"id", "tags", "meta", "created_at", "updated_at"},
	PKColumns: []string{"id"},
	Scan: func(row drel.Row) (*JSONDoc, error) {
		p := &JSONDoc{}
		idPtr, createdAtPtr, updatedAtPtr := p.ScanPtrs()
		err := row.Scan(idPtr, drel.JSON[[]string]{V: &p.Tags}, drel.JSON[map[string]string]{V: &p.Meta}, createdAtPtr, updatedAtPtr)
		if err != nil {
			return nil, err
		}
		return p, nil
	},
	Snapshot: func(p *JSONDoc) any { return jsonDocSnapshot{Tags: p.Tags, Meta: p.Meta} },
	Diff: func(p *JSONDoc, snap any) []drel.FieldChange {
		s := snap.(jsonDocSnapshot)
		var changes []drel.FieldChange
		if !slicesEqual(p.Tags, s.Tags) {
			changes = append(changes, drel.FieldChange{Column: "tags", Value: drel.JSON[[]string]{V: &p.Tags}})
		}
		if !mapsEqual(p.Meta, s.Meta) {
			changes = append(changes, drel.FieldChange{Column: "meta", Value: drel.JSON[map[string]string]{V: &p.Meta}})
		}
		return changes
	},
	PKValue: func(p *JSONDoc) any { return p.ID() },
	InsertColumns: func(p *JSONDoc) ([]string, []any) {
		return []string{"tags", "meta"}, []any{drel.JSON[[]string]{V: &p.Tags}, drel.JSON[map[string]string]{V: &p.Meta}}
	},
	ScanReturning: func(p *JSONDoc, row drel.Row) error {
		idPtr, createdAtPtr, updatedAtPtr := p.ScanPtrs()
		return row.Scan(idPtr, createdAtPtr, updatedAtPtr)
	},
	ColumnValue: func(p *JSONDoc, idx int) any {
		switch idx {
		case 0:
			return p.ID()
		case 1:
			return drel.JSON[[]string]{V: &p.Tags}
		case 2:
			return drel.JSON[map[string]string]{V: &p.Meta}
		case 3:
			return p.CreatedAt()
		case 4:
			return p.UpdatedAt()
		}
		return nil
	},
	NormalizeKey: func(v any) any { return drel.NormalizeIntKey(v) },
}
View Source
var OrderLineMeta = drel.ModelMeta[OrderLine]{
	Table:         "order_lines",
	Columns:       []string{"order_id", "line_no", "qty", "created_at", "updated_at"},
	PKColumns:     []string{"order_id", "line_no"},
	Scan:          scanOrderline,
	Snapshot:      snapshotOrderline,
	Diff:          diffOrderline,
	PKValue:       orderlinePKValue,
	KeyValues:     orderlineKeyValues,
	InsertColumns: orderlineInsertColumns,
	ScanReturning: orderlineScanReturning,
	ColumnValue:   orderlineColumnValue,
	NormalizeKey:  orderlineNormalizeKey,
	KeyStrategy:   drel.KeyAppAssigned,
	SetKey:        func(p *OrderLine, key any) { p.SetID(key.(OrderLineKey)) },
	KeyIsZero:     orderlineKeyIsZero,
	ScanGenerated: orderlineScanGenerated,
}
View Source
var OrderLines = struct {
	OrderID   drel.OrderedColumn[int]
	LineNo    drel.ComparableColumn[LineNo]
	Qty       drel.OrderedColumn[int]
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	OrderID:   drel.NewOrderedCol[int]("order_id"),
	LineNo:    drel.NewComparableCol[LineNo]("line_no"),
	Qty:       drel.NewOrderedCol[int]("qty"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}
View Source
var ProductMeta = drel.ModelMeta[Product]{
	Table:     "products",
	Columns:   []string{"id", "name", "price", "in_stock", "created_at", "updated_at"},
	PKColumns: []string{"id"},
	Scan: func(row drel.Row) (*Product, error) {
		p := &Product{}
		err := row.Scan(&p.ID, &p.Name, &p.Price, &p.InStock, &p.CreatedAt, &p.UpdatedAt)
		if err != nil {
			return nil, err
		}
		return p, nil
	},
	Snapshot: func(p *Product) any {
		return productSnapshot{Name: p.Name, Price: p.Price, InStock: p.InStock}
	},
	Diff: func(p *Product, snap any) []drel.FieldChange {
		s := snap.(productSnapshot)
		var changes []drel.FieldChange
		if p.Name != s.Name {
			changes = append(changes, drel.FieldChange{Column: "name", Value: p.Name})
		}
		if p.Price != s.Price {
			changes = append(changes, drel.FieldChange{Column: "price", Value: p.Price})
		}
		if p.InStock != s.InStock {
			changes = append(changes, drel.FieldChange{Column: "in_stock", Value: p.InStock})
		}
		return changes
	},
	PKValue: func(p *Product) any {
		return p.ID
	},
	ColumnValue: func(p *Product, idx int) any {
		switch idx {
		case 0:
			return p.ID
		case 1:
			return p.Name
		case 2:
			return p.Price
		case 3:
			return p.InStock
		case 4:
			return p.CreatedAt
		case 5:
			return p.UpdatedAt
		}
		return nil
	},
	InsertColumns: func(p *Product) ([]string, []any) {
		return []string{"name", "price", "in_stock"}, []any{p.Name, p.Price, p.InStock}
	},
	ScanReturning: func(p *Product, row drel.Row) error {
		return row.Scan(&p.ID, &p.CreatedAt, &p.UpdatedAt)
	},
}
View Source
var Products = struct {
	ID        drel.OrderedColumn[int]
	Name      drel.StringColumn
	Price     drel.OrderedColumn[int]
	InStock   drel.BoolColumn
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	ID:        drel.NewOrderedCol[int]("id"),
	Name:      drel.NewStringCol("name"),
	Price:     drel.NewOrderedCol[int]("price"),
	InStock:   drel.NewBoolCol("in_stock"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}
View Source
var SoftDeleteProductMeta = drel.ModelMeta[SoftDeleteProduct]{
	Table:         "sd_products",
	Columns:       []string{"id", "name", "price", "deleted_at", "created_at", "updated_at"},
	PKColumns:     []string{"id"},
	HasSoftDelete: true,
	Filters: []drel.NamedFilter{
		{Name: "soft_delete", Clause: ast.WhereClause{
			Comparison: &ast.ComparisonNode{Column: "deleted_at", Op: ast.OpIsNull},
		}},
	},
	Scan: func(row drel.Row) (*SoftDeleteProduct, error) {
		p := &SoftDeleteProduct{}
		idPtr, createdAtPtr, updatedAtPtr := p.ScanPtrs()
		err := row.Scan(idPtr, &p.name, &p.price, p.DeletedAtPtr(), createdAtPtr, updatedAtPtr)
		if err != nil {
			return nil, err
		}
		return p, nil
	},
	Snapshot: func(p *SoftDeleteProduct) any {
		return sdProductSnapshot{name: p.name, price: p.price}
	},
	Diff: func(p *SoftDeleteProduct, snap any) []drel.FieldChange {
		s := snap.(sdProductSnapshot)
		var changes []drel.FieldChange
		if p.name != s.name {
			changes = append(changes, drel.FieldChange{Column: "name", Value: p.name})
		}
		if p.price != s.price {
			changes = append(changes, drel.FieldChange{Column: "price", Value: p.price})
		}
		return changes
	},
	PKValue: func(p *SoftDeleteProduct) any { return p.ID() },
	InsertColumns: func(p *SoftDeleteProduct) ([]string, []any) {
		return []string{"name", "price"}, []any{p.name, p.price}
	},
	ScanReturning: func(p *SoftDeleteProduct, row drel.Row) error {
		idPtr, createdAtPtr, updatedAtPtr := p.ScanPtrs()
		return row.Scan(idPtr, createdAtPtr, updatedAtPtr)
	},
}
View Source
var SoftDeleteProducts = struct {
	ID        drel.OrderedColumn[int]
	Name      drel.StringColumn
	Price     drel.OrderedColumn[int]
	DeletedAt drel.ComparableColumn[*time.Time]
}{
	ID:        drel.NewOrderedCol[int]("id"),
	Name:      drel.NewStringCol("name"),
	Price:     drel.NewOrderedCol[int]("price"),
	DeletedAt: drel.NewComparableCol[*time.Time]("deleted_at"),
}
View Source
var SoftOrderLineMeta = drel.ModelMeta[SoftOrderLine]{
	Table:         "soft_order_lines",
	Columns:       []string{"order_id", "line_no", "qty", "deleted_at", "created_at", "updated_at"},
	PKColumns:     []string{"order_id", "line_no"},
	Scan:          scanSoftorderline,
	Snapshot:      snapshotSoftorderline,
	Diff:          diffSoftorderline,
	PKValue:       softorderlinePKValue,
	KeyValues:     softorderlineKeyValues,
	InsertColumns: softorderlineInsertColumns,
	ScanReturning: softorderlineScanReturning,
	ColumnValue:   softorderlineColumnValue,
	NormalizeKey:  softorderlineNormalizeKey,
	KeyStrategy:   drel.KeyAppAssigned,
	SetKey:        func(p *SoftOrderLine, key any) { p.SetID(key.(OrderLineKey)) },
	KeyIsZero:     softorderlineKeyIsZero,
	ScanGenerated: softorderlineScanGenerated,
	HasSoftDelete: true,
	Filters:       []drel.NamedFilter{drel.SoftDeleteFilter},
}
View Source
var SoftOrderLines = struct {
	OrderID   drel.OrderedColumn[int]
	LineNo    drel.ComparableColumn[LineNo]
	Qty       drel.OrderedColumn[int]
	DeletedAt drel.ComparableColumn[*time.Time]
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	OrderID:   drel.NewOrderedCol[int]("order_id"),
	LineNo:    drel.NewComparableCol[LineNo]("line_no"),
	Qty:       drel.NewOrderedCol[int]("qty"),
	DeletedAt: drel.NewComparableCol[*time.Time]("deleted_at"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}
View Source
var SoftVersionedOrderLineMeta = drel.ModelMeta[SoftVersionedOrderLine]{
	Table:         "soft_versioned_order_lines",
	Columns:       []string{"order_id", "line_no", "qty", "deleted_at", "version", "created_at", "updated_at"},
	PKColumns:     []string{"order_id", "line_no"},
	Scan:          scanSoftversionedorderline,
	Snapshot:      snapshotSoftversionedorderline,
	Diff:          diffSoftversionedorderline,
	PKValue:       softversionedorderlinePKValue,
	KeyValues:     softversionedorderlineKeyValues,
	InsertColumns: softversionedorderlineInsertColumns,
	ScanReturning: softversionedorderlineScanReturning,
	ColumnValue:   softversionedorderlineColumnValue,
	NormalizeKey:  softversionedorderlineNormalizeKey,
	KeyStrategy:   drel.KeyAppAssigned,
	SetKey:        func(p *SoftVersionedOrderLine, key any) { p.SetID(key.(OrderLineKey)) },
	KeyIsZero:     softversionedorderlineKeyIsZero,
	ScanGenerated: softversionedorderlineScanGenerated,
	HasSoftDelete: true,
	Filters:       []drel.NamedFilter{drel.SoftDeleteFilter},
	HasVersioned:  true,
	VersionValue:  func(p *SoftVersionedOrderLine) int { return p.Version() },
	SetVersion:    func(p *SoftVersionedOrderLine, v int) { *p.VersionPtr() = v },
}
View Source
var SoftVersionedOrderLines = struct {
	OrderID   drel.OrderedColumn[int]
	LineNo    drel.ComparableColumn[LineNo]
	Qty       drel.OrderedColumn[int]
	DeletedAt drel.ComparableColumn[*time.Time]
	Version   drel.OrderedColumn[int]
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	OrderID:   drel.NewOrderedCol[int]("order_id"),
	LineNo:    drel.NewComparableCol[LineNo]("line_no"),
	Qty:       drel.NewOrderedCol[int]("qty"),
	DeletedAt: drel.NewComparableCol[*time.Time]("deleted_at"),
	Version:   drel.NewOrderedCol[int]("version"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}
View Source
var TenantDocMeta = drel.ModelMeta[TenantDoc]{
	Table:         "tenant_docs",
	Columns:       []string{"tenant_id", "doc_no", "title", "created_at", "updated_at"},
	PKColumns:     []string{"tenant_id", "doc_no"},
	Scan:          scanTenantdoc,
	Snapshot:      snapshotTenantdoc,
	Diff:          diffTenantdoc,
	PKValue:       tenantdocPKValue,
	KeyValues:     tenantdocKeyValues,
	InsertColumns: tenantdocInsertColumns,
	ScanReturning: tenantdocScanReturning,
	ColumnValue:   tenantdocColumnValue,
	NormalizeKey:  tenantdocNormalizeKey,
	KeyStrategy:   drel.KeyAppAssigned,
	SetKey:        func(p *TenantDoc, key any) { p.SetID(key.(TenantDocKey)) },
	KeyIsZero:     tenantdocKeyIsZero,
	ScanGenerated: tenantdocScanGenerated,
}
View Source
var TenantDocs = struct {
	TenantID  drel.ComparableColumn[uuid.UUID]
	DocNo     drel.OrderedColumn[int]
	Title     drel.StringColumn
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	TenantID:  drel.NewComparableCol[uuid.UUID]("tenant_id"),
	DocNo:     drel.NewOrderedCol[int]("doc_no"),
	Title:     drel.NewStringCol("title"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}
View Source
var VersionedOrderLineMeta = drel.ModelMeta[VersionedOrderLine]{
	Table:         "versioned_order_lines",
	Columns:       []string{"order_id", "line_no", "qty", "version", "created_at", "updated_at"},
	PKColumns:     []string{"order_id", "line_no"},
	Scan:          scanVersionedorderline,
	Snapshot:      snapshotVersionedorderline,
	Diff:          diffVersionedorderline,
	PKValue:       versionedorderlinePKValue,
	KeyValues:     versionedorderlineKeyValues,
	InsertColumns: versionedorderlineInsertColumns,
	ScanReturning: versionedorderlineScanReturning,
	ColumnValue:   versionedorderlineColumnValue,
	NormalizeKey:  versionedorderlineNormalizeKey,
	KeyStrategy:   drel.KeyAppAssigned,
	SetKey:        func(p *VersionedOrderLine, key any) { p.SetID(key.(OrderLineKey)) },
	KeyIsZero:     versionedorderlineKeyIsZero,
	ScanGenerated: versionedorderlineScanGenerated,
	HasVersioned:  true,
	VersionValue:  func(p *VersionedOrderLine) int { return p.Version() },
	SetVersion:    func(p *VersionedOrderLine, v int) { *p.VersionPtr() = v },
}
View Source
var VersionedOrderLines = struct {
	OrderID   drel.OrderedColumn[int]
	LineNo    drel.ComparableColumn[LineNo]
	Qty       drel.OrderedColumn[int]
	Version   drel.OrderedColumn[int]
	CreatedAt drel.TimeColumn
	UpdatedAt drel.TimeColumn
}{
	OrderID:   drel.NewOrderedCol[int]("order_id"),
	LineNo:    drel.NewComparableCol[LineNo]("line_no"),
	Qty:       drel.NewOrderedCol[int]("qty"),
	Version:   drel.NewOrderedCol[int]("version"),
	CreatedAt: drel.NewTimeCol("created_at"),
	UpdatedAt: drel.NewTimeCol("updated_at"),
}
View Source
var VersionedProductMeta = drel.ModelMeta[VersionedProduct]{
	Table:        "v_products",
	Columns:      []string{"id", "name", "price", "version", "created_at", "updated_at"},
	PKColumns:    []string{"id"},
	HasVersioned: true,
	VersionValue: func(p *VersionedProduct) int { return p.Version() },
	SetVersion:   func(p *VersionedProduct, v int) { *p.VersionPtr() = v },
	Scan: func(row drel.Row) (*VersionedProduct, error) {
		p := &VersionedProduct{}
		idPtr, createdAtPtr, updatedAtPtr := p.ScanPtrs()
		err := row.Scan(idPtr, &p.name, &p.price, p.VersionPtr(), createdAtPtr, updatedAtPtr)
		if err != nil {
			return nil, err
		}
		return p, nil
	},
	Snapshot: func(p *VersionedProduct) any {
		return vpSnapshot{name: p.name, price: p.price}
	},
	Diff: func(p *VersionedProduct, snap any) []drel.FieldChange {
		s := snap.(vpSnapshot)
		var changes []drel.FieldChange
		if p.name != s.name {
			changes = append(changes, drel.FieldChange{Column: "name", Value: p.name})
		}
		if p.price != s.price {
			changes = append(changes, drel.FieldChange{Column: "price", Value: p.price})
		}
		return changes
	},
	PKValue: func(p *VersionedProduct) any { return p.ID() },
	InsertColumns: func(p *VersionedProduct) ([]string, []any) {
		return []string{"name", "price"}, []any{p.name, p.price}
	},
	ScanReturning: func(p *VersionedProduct, row drel.Row) error {
		idPtr, createdAtPtr, updatedAtPtr := p.ScanPtrs()
		return row.Scan(idPtr, createdAtPtr, updatedAtPtr)
	},
}

Functions

This section is empty.

Types

type AuditOrderLine added in v0.8.1

type AuditOrderLine struct {
	drel.Model[OrderLineKey]
	drel.Audit
	Qty int `db:"qty"`
}

AuditOrderLine exercises the audit trait with a composite key. The generated column list interleaves the trait columns with the two key columns, so the insert, the scan and the update must all keep the columns aligned.

type AuditOrderLineRepository added in v0.8.1

type AuditOrderLineRepository struct {
	*drel.Repository[AuditOrderLine]
}

func (*AuditOrderLineRepository) FindByID added in v0.8.1

type AuditProduct

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

func NewAuditProduct

func NewAuditProduct(name string, price int) *AuditProduct

func (*AuditProduct) Name

func (p *AuditProduct) Name() string

func (*AuditProduct) Price

func (p *AuditProduct) Price() int

func (*AuditProduct) SetName

func (p *AuditProduct) SetName(n string)

func (*AuditProduct) SetPrice

func (p *AuditProduct) SetPrice(pr int)

type EventUser

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

func NewEventUser

func NewEventUser(name, email string) *EventUser

func (*EventUser) Email

func (u *EventUser) Email() string

func (*EventUser) Name

func (u *EventUser) Name() string

type JSONDoc added in v0.5.0

type JSONDoc struct {
	drel.Model[int]
	Tags []string          `db:"tags"`
	Meta map[string]string `db:"meta"`
}

JSONDoc exercises JSON (jsonb) and JSON-array columns end-to-end.

type LineNo added in v0.8.0

type LineNo int

LineNo is a named type over int. The driver returns int64 for the column, so the key path must convert rather than assert. This is the failure shape that the m2m relationship once had.

type OrderLine added in v0.8.0

type OrderLine struct {
	drel.Model[OrderLineKey]
	Qty int `db:"qty"`
}

OrderLine exercises insert, find, update and delete with a composite key.

type OrderLineKey added in v0.8.0

type OrderLineKey struct {
	OrderID int    `db:"order_id"`
	LineNo  LineNo `db:"line_no"`
}

OrderLineKey is a two-column primary key with a named-type column.

type OrderLineRepository added in v0.8.0

type OrderLineRepository struct {
	*drel.Repository[OrderLine]
}

func (*OrderLineRepository) FindByID added in v0.8.0

type Product

type Product struct {
	ID        int
	Name      string
	Price     int
	InStock   bool
	CreatedAt time.Time
	UpdatedAt time.Time
}

type SoftDeleteProduct

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

func NewSoftDeleteProduct

func NewSoftDeleteProduct(name string, price int) *SoftDeleteProduct

func (*SoftDeleteProduct) Name

func (p *SoftDeleteProduct) Name() string

func (*SoftDeleteProduct) Price

func (p *SoftDeleteProduct) Price() int

func (*SoftDeleteProduct) SetName

func (p *SoftDeleteProduct) SetName(n string)

func (*SoftDeleteProduct) SetPrice

func (p *SoftDeleteProduct) SetPrice(pr int)

type SoftOrderLine added in v0.8.0

type SoftOrderLine struct {
	drel.Model[OrderLineKey]
	drel.SoftDelete
	Qty int `db:"qty"`
}

SoftOrderLine exercises the soft-delete path with a composite key.

type SoftOrderLineRepository added in v0.8.0

type SoftOrderLineRepository struct {
	*drel.Repository[SoftOrderLine]
}

func (*SoftOrderLineRepository) FindByID added in v0.8.0

type SoftVersionedOrderLine added in v0.8.0

type SoftVersionedOrderLine struct {
	drel.Model[OrderLineKey]
	drel.Versioned
	drel.SoftDelete
	Qty int `db:"qty"`
}

SoftVersionedOrderLine exercises the versioned soft delete with a composite key.

type SoftVersionedOrderLineRepository added in v0.8.0

type SoftVersionedOrderLineRepository struct {
	*drel.Repository[SoftVersionedOrderLine]
}

func (*SoftVersionedOrderLineRepository) FindByID added in v0.8.0

type TenantDoc added in v0.8.0

type TenantDoc struct {
	drel.Model[TenantDocKey]
	Title string `db:"title"`
}

TenantDoc exercises a composite key that contains a uuid column.

type TenantDocKey added in v0.8.0

type TenantDocKey struct {
	TenantID uuid.UUID `db:"tenant_id"`
	DocNo    int       `db:"doc_no"`
}

TenantDocKey is a composite key whose first column is a uuid.

type TenantDocRepository added in v0.8.0

type TenantDocRepository struct {
	*drel.Repository[TenantDoc]
}

func (*TenantDocRepository) FindByID added in v0.8.0

type TxAuditOrderLineRepository added in v0.8.1

type TxAuditOrderLineRepository struct {
	*drel.TxRepository[AuditOrderLine]
}

func (*TxAuditOrderLineRepository) FindByID added in v0.8.1

type TxOrderLineRepository added in v0.8.0

type TxOrderLineRepository struct {
	*drel.TxRepository[OrderLine]
}

func (*TxOrderLineRepository) FindByID added in v0.8.0

type TxSoftOrderLineRepository added in v0.8.0

type TxSoftOrderLineRepository struct {
	*drel.TxRepository[SoftOrderLine]
}

func (*TxSoftOrderLineRepository) FindByID added in v0.8.0

type TxSoftVersionedOrderLineRepository added in v0.8.0

type TxSoftVersionedOrderLineRepository struct {
	*drel.TxRepository[SoftVersionedOrderLine]
}

func (*TxSoftVersionedOrderLineRepository) FindByID added in v0.8.0

type TxTenantDocRepository added in v0.8.0

type TxTenantDocRepository struct {
	*drel.TxRepository[TenantDoc]
}

func (*TxTenantDocRepository) FindByID added in v0.8.0

type TxVersionedOrderLineRepository added in v0.8.0

type TxVersionedOrderLineRepository struct {
	*drel.TxRepository[VersionedOrderLine]
}

func (*TxVersionedOrderLineRepository) FindByID added in v0.8.0

type VersionedOrderLine added in v0.8.0

type VersionedOrderLine struct {
	drel.Model[OrderLineKey]
	drel.Versioned
	Qty int `db:"qty"`
}

VersionedOrderLine exercises the versioned update and the versioned hard delete with a composite key.

type VersionedOrderLineRepository added in v0.8.0

type VersionedOrderLineRepository struct {
	*drel.Repository[VersionedOrderLine]
}

func (*VersionedOrderLineRepository) FindByID added in v0.8.0

type VersionedProduct

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

func NewVersionedProduct

func NewVersionedProduct(name string, price int) *VersionedProduct

func (*VersionedProduct) Name

func (p *VersionedProduct) Name() string

func (*VersionedProduct) Price

func (p *VersionedProduct) Price() int

func (*VersionedProduct) SetName

func (p *VersionedProduct) SetName(n string)

func (*VersionedProduct) SetPrice

func (p *VersionedProduct) SetPrice(pr int)

Jump to

Keyboard shortcuts

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