mysql

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package mysql implements the various domain entity repositories and includes a Backend that groups them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(ctx context.Context, db *sql.DB, table string) error

Migrate runs the migrations on the provided DB using the provided table to track them.

Types

type Backend

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

Backend is the MySQL implementation of the costestimation.Backend, using repositories that connect to a MySQL database.

func NewBackend

func NewBackend(querier sqlr.Querier) *Backend

NewBackend returns a new Backend with a product.Repository and a price.Repository included.

func (*Backend) Prices

func (b *Backend) Prices() price.Repository

Prices returns the price.Repository that uses the Backend's querier.

func (*Backend) Products

func (b *Backend) Products() product.Repository

Products returns the product.Repository that uses the Backend's querier.

type PriceRepository

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

PriceRepository implements the price.Repository.

func NewPriceRepository

func NewPriceRepository(querier sqlr.Querier) *PriceRepository

NewPriceRepository returns an implementation of price.Repository.

func (*PriceRepository) DeleteByProductWithKeep

func (r *PriceRepository) DeleteByProductWithKeep(ctx context.Context, productID product.ID, keep []price.ID) error

DeleteByProductWithKeep deletes all the prices of the product with given product.ID except the ones in the keep slice.

func (*PriceRepository) Filter

func (r *PriceRepository) Filter(ctx context.Context, productID product.ID, filter *price.Filter) ([]*price.Price, error)

Filter returns all the price.Price that belong to a given product with given product.ID and that matches the price.Filter.

func (*PriceRepository) Upsert

func (r *PriceRepository) Upsert(ctx context.Context, pwp *price.WithProduct) (price.ID, error)

Upsert updates a price.WithProduct if it exists or inserts it otherwise.

type ProductRepository

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

ProductRepository implements the product.Repository.

func NewProductRepository

func NewProductRepository(querier sqlr.Querier) *ProductRepository

NewProductRepository returns an implementation of product.Repository.

func (*ProductRepository) Filter

func (r *ProductRepository) Filter(ctx context.Context, filter *product.Filter) ([]*product.Product, error)

Filter returns all the product.Product that match the given product.Filter.

func (*ProductRepository) FindByVendorAndSKU

func (r *ProductRepository) FindByVendorAndSKU(ctx context.Context, vendor, sku string) (*product.Product, error)

FindByVendorAndSKU returns a single product.Product of the given vendor and sku.

func (*ProductRepository) Upsert

func (r *ProductRepository) Upsert(ctx context.Context, prod *product.Product) (product.ID, error)

Upsert updates a product.Product if it exists or inserts a new one otherwise.

type Where

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

Where represents the parts of a SQL WHERE clause.

func (*Where) Parameters

func (w *Where) Parameters() []interface{}

Parameters returns the slice of parameters to be passed to the Exec or Query method.

func (*Where) String

func (w *Where) String() string

String returns the string of the WHERE clause.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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