Documentation ¶
Overview ¶
Package homebus provides business access to home domain.
Index ¶
- Constants
- Variables
- type Address
- type Business
- func (b *Business) Count(ctx context.Context, filter QueryFilter) (int, error)
- func (b *Business) Create(ctx context.Context, nh NewHome) (Home, error)
- func (b *Business) Delete(ctx context.Context, hme Home) error
- func (b *Business) NewWithTx(tx sqldb.CommitRollbacker) (*Business, error)
- func (b *Business) Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]Home, error)
- func (b *Business) QueryByID(ctx context.Context, homeID uuid.UUID) (Home, error)
- func (b *Business) QueryByUserID(ctx context.Context, userID uuid.UUID) ([]Home, error)
- func (b *Business) Update(ctx context.Context, hme Home, uh UpdateHome) (Home, error)
- type Home
- type NewHome
- type QueryFilter
- type Storer
- type UpdateAddress
- type UpdateHome
Constants ¶
const ( OrderByID = "home_id" OrderByType = "type" OrderByUserID = "user_id" )
Set of fields that the results can be ordered by.
Variables ¶
var ( ErrNotFound = errors.New("home not found") ErrUserDisabled = errors.New("user disabled") )
Set of error variables for CRUD operations.
DefaultOrderBy represents the default way we sort.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct { Address1 string // We should create types for these fields. Address2 string ZipCode string City string State string Country string }
Address represents an individual address.
type Business ¶
type Business struct {
// contains filtered or unexported fields
}
Business manages the set of APIs for home api access.
func NewBusiness ¶
func NewBusiness(log *logger.Logger, userBus *userbus.Business, delegate *delegate.Delegate, storer Storer) *Business
NewBusiness constructs a home business API for use.
func (*Business) NewWithTx ¶
func (b *Business) NewWithTx(tx sqldb.CommitRollbacker) (*Business, error)
NewWithTx constructs a new domain value that will use the specified transaction in any store related calls.
func (*Business) Query ¶
func (b *Business) Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]Home, error)
Query retrieves a list of existing homes.
func (*Business) QueryByUserID ¶
QueryByUserID finds the homes by a specified User ID.
type Home ¶
type Home struct { ID uuid.UUID UserID uuid.UUID Type hometype.HomeType Address Address DateCreated time.Time DateUpdated time.Time }
Home represents an individual home.
type QueryFilter ¶
type QueryFilter struct { ID *uuid.UUID UserID *uuid.UUID Type *hometype.HomeType StartCreatedDate *time.Time EndCreatedDate *time.Time }
QueryFilter holds the available fields a query can be filtered on. We are using pointer semantics because the With API mutates the value.
type Storer ¶
type Storer interface { NewWithTx(tx sqldb.CommitRollbacker) (Storer, error) Create(ctx context.Context, hme Home) error Update(ctx context.Context, hme Home) error Delete(ctx context.Context, hme Home) error Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]Home, error) Count(ctx context.Context, filter QueryFilter) (int, error) QueryByID(ctx context.Context, homeID uuid.UUID) (Home, error) QueryByUserID(ctx context.Context, userID uuid.UUID) ([]Home, error) }
Storer interface declares the behaviour this package needs to persist and retrieve data.
type UpdateAddress ¶
type UpdateAddress struct { Address1 *string Address2 *string ZipCode *string City *string State *string Country *string }
UpdateAddress is what fields can be updated in the store.
type UpdateHome ¶
type UpdateHome struct { Type *hometype.HomeType Address *UpdateAddress }
UpdateHome defines what information may be provided to modify an existing Home. All fields are optional so clients can send only the fields they want changed. It uses pointer fields so we can differentiate between a field that was not provided and a field that was provided as explicitly blank. Normally we do not want to use pointers to basic types but we make exception around marshalling/unmarshalling.