models

package
v0.0.0-...-aee760d Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAssetNotFound = fmt.Errorf("asset not found: %w", ErrNotFound)
View Source
var ErrAssetSerialNotUnique = errors.New("serial not unique within model")
View Source
var ErrModelHasAssets = errors.New("model contains assets")
View Source
var ErrModelNotFound = fmt.Errorf("model not found: %w", ErrNotFound)
View Source
var ErrModelNotUnique = errors.New("model not unique within vendor")
View Source
var ErrNotFound = errors.New("not found")

ErrNotFound indicates the resource being queried for does not exist.

View Source
var ErrVendorHasModels = errors.New("vendor with models cannot be deleted")
View Source
var ErrVendorNotFound = fmt.Errorf("vendor not found: %w", ErrNotFound)

Functions

This section is empty.

Types

type Asset

type Asset struct {
	ID        int64
	ModelID   int64
	VendorID  int64
	Serial    string
	Comments  string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type AssetModel

type AssetModel struct {
	// contains filtered or unexported fields
}

func NewAssetModel

func NewAssetModel(logger *slog.Logger, db queries.DBTX, validate *validator.Validate) *AssetModel

func (*AssetModel) Create

func (m *AssetModel) Create(ctx context.Context, asset NewAsset) (Asset, error)

func (*AssetModel) DeleteByID

func (m *AssetModel) DeleteByID(ctx context.Context, id int64) error

func (*AssetModel) GetByID

func (m *AssetModel) GetByID(ctx context.Context, id int64) (Asset, error)

func (*AssetModel) List

func (m *AssetModel) List(ctx context.Context) ([]Asset, error)

func (*AssetModel) ListByModel

func (m *AssetModel) ListByModel(ctx context.Context, modelID int64) ([]Asset, error)

func (*AssetModel) UpdateByID

func (m *AssetModel) UpdateByID(ctx context.Context, id int64, asset NewAsset) (Asset, error)

type Model

type Model struct {
	ID        int64
	VendorID  int64
	Model     string
	Name      string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type ModelModel

type ModelModel struct {
	// contains filtered or unexported fields
}

func NewModelModel

func NewModelModel(logger *slog.Logger, db queries.DBTX, validate *validator.Validate) *ModelModel

func (*ModelModel) Create

func (m *ModelModel) Create(ctx context.Context, model NewModel) (Model, error)

func (*ModelModel) DeleteByID

func (m *ModelModel) DeleteByID(ctx context.Context, id int64) error

func (*ModelModel) GetByID

func (m *ModelModel) GetByID(ctx context.Context, id int64) (Model, error)

func (*ModelModel) ListByVendorID

func (m *ModelModel) ListByVendorID(ctx context.Context, vendorID int64) ([]Model, error)

func (*ModelModel) ListModels

func (m *ModelModel) ListModels(ctx context.Context) ([]Model, error)

func (*ModelModel) UpdateByID

func (m *ModelModel) UpdateByID(ctx context.Context, id int64, model NewModel) (Model, error)

type NewAsset

type NewAsset struct {
	ModelID  int64  `json:"modelID"`
	Serial   string `json:"serial"   conform:"trim" validate:"required,min=1,max=150"`
	Comments string `json:"comments" conform:"trim" validate:"max=1000"`
}

type NewModel

type NewModel struct {
	VendorID int64  `json:"vendorID"`
	Model    string `json:"model"    conform:"trim" validate:"required,min=1,max=150"`
	Name     string `json:"name"     conform:"trim" validate:"max=150"`
}

type NewVendor

type NewVendor struct {
	Name string `json:"name" conform:"trim" validate:"required,min=1,max=150"`
}

type Vendor

type Vendor struct {
	ID        int64
	Name      string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type VendorModel

type VendorModel struct {
	// contains filtered or unexported fields
}

func NewVendorModel

func NewVendorModel(logger *slog.Logger, db queries.DBTX, validate *validator.Validate) *VendorModel

func (*VendorModel) Create

func (m *VendorModel) Create(ctx context.Context, vendor NewVendor) (Vendor, error)

func (*VendorModel) DeleteByID

func (m *VendorModel) DeleteByID(ctx context.Context, id int64) error

func (*VendorModel) GetByID

func (m *VendorModel) GetByID(ctx context.Context, id int64) (Vendor, error)

func (*VendorModel) ListVendors

func (m *VendorModel) ListVendors(ctx context.Context) ([]Vendor, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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