Documentation ¶
Overview ¶
Package mysql implements the various domain entity repositories and includes a Backend that groups them.
Index ¶
- func Migrate(ctx context.Context, db *sql.DB, table string) error
- type Backend
- type PriceRepository
- func (r *PriceRepository) DeleteByProductWithKeep(ctx context.Context, productID product.ID, keep []price.ID) error
- func (r *PriceRepository) Filter(ctx context.Context, productID product.ID, filter *price.Filter) ([]*price.Price, error)
- func (r *PriceRepository) Upsert(ctx context.Context, pwp *price.WithProduct) (price.ID, error)
- type ProductRepository
- func (r *ProductRepository) Filter(ctx context.Context, filter *product.Filter) ([]*product.Product, error)
- func (r *ProductRepository) FindByVendorAndSKU(ctx context.Context, vendor, sku string) (*product.Product, error)
- func (r *ProductRepository) Upsert(ctx context.Context, prod *product.Product) (product.ID, error)
- type Where
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
NewBackend returns a new Backend with a product.Repository and a price.Repository included.
func (*Backend) Prices ¶ added in v0.5.0
func (b *Backend) Prices() price.Repository
Prices returns the price.Repository that uses the Backend's querier.
func (*Backend) Products ¶ added in v0.5.0
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.
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.