Documentation ¶
Overview ¶
Package vproduct provides an example of a core business API that is based on a view.
Index ¶
Constants ¶
const ( OrderByProductID = "product_id" OrderByUserID = "user_id" OrderByName = "name" OrderByCost = "cost" OrderByQuantity = "quantity" OrderByUserName = "user_name" )
Set of fields that the results can be ordered by.
Variables ¶
var DefaultOrderBy = order.NewBy(OrderByProductID, order.ASC)
DefaultOrderBy represents the default way we sort.
Functions ¶
This section is empty.
Types ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core manages the set of APIs for user access.
type Product ¶
type Product struct { ID uuid.UUID UserID uuid.UUID Name string Cost float64 Quantity int DateCreated time.Time DateUpdated time.Time UserName string }
Product represents an individual product with extended information.
type QueryFilter ¶
type QueryFilter struct { ID *uuid.UUID Name *string `validate:"omitempty,min=3"` Cost *float64 Quantity *int UserName *string }
QueryFilter holds the available fields a query can be filtered on. We are using pointer semantics because the With API mutates the value.
func (*QueryFilter) Validate ¶
func (qf *QueryFilter) Validate() error
Validate can perform a check of the data against the validate tags.
func (*QueryFilter) WithCost ¶
func (qf *QueryFilter) WithCost(cost float64)
WithCost sets the Cost field of the QueryFilter value.
func (*QueryFilter) WithID ¶
func (qf *QueryFilter) WithID(productID uuid.UUID)
WithID sets the ID field of the QueryFilter value.
func (*QueryFilter) WithName ¶
func (qf *QueryFilter) WithName(name string)
WithName sets the Name field of the QueryFilter value.
func (*QueryFilter) WithQuantity ¶
func (qf *QueryFilter) WithQuantity(quantity int)
WithQuantity sets the Quantity field of the QueryFilter value.
func (*QueryFilter) WithUserName ¶
func (qf *QueryFilter) WithUserName(userName string)
WithUserName sets the UserName field of the QueryFilter value.
type Storer ¶
type Storer interface { Query(ctx context.Context, filter QueryFilter, orderBy order.By, pageNumber int, rowsPerPage int) ([]Product, error) Count(ctx context.Context, filter QueryFilter) (int, error) }
Storer interface declares the behavior this package needs to perists and retrieve data.
Directories ¶
Path | Synopsis |
---|---|
stores
|
|
vproductdb
Package vproductdb provides access to the product view.
|
Package vproductdb provides access to the product view. |