streetbus

package
v0.0.0-...-16ef530 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderByID         = "street_id"
	OrderByCityID     = "city_id"
	OrderByLine1      = "line_1"
	OrderByLine2      = "line_2"
	OrderByPostalCode = "postal_code"
)

Set of fields that the results can be ordered by.

Variables

View Source
var (
	ErrNotFound              = errors.New("street not found")
	ErrAuthenticationFailure = errors.New("authentication failed")
	ErrUniqueEntry           = errors.New("street entry is not unique")
)

Set of error variables for CRUD operations.

View Source
var DefaultOrderBy = order.NewBy(OrderByLine1, order.ASC)

DefaultOrderBy represents the default way we sort.

Functions

This section is empty.

Types

type Business

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

Business manages the set of APIs for street access.

func NewBusiness

func NewBusiness(log *logger.Logger, delegate *delegate.Delegate, storer Storer) *Business

NewBusiness constructs a street business API for use.

func (*Business) Count

func (b *Business) Count(ctx context.Context, filter QueryFilter) (int, error)

Count returns the total number of cities.

func (*Business) Create

func (b *Business) Create(ctx context.Context, ns NewStreet) (Street, error)

Create adds a new street to the system.

func (*Business) Delete

func (b *Business) Delete(ctx context.Context, str Street) error

Delete removes a street from the system.

func (*Business) NewWithTx

func (b *Business) NewWithTx(tx sqldb.CommitRollbacker) (*Business, error)

NewWithTx constructs a new business 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) ([]Street, error)

Query retrieves a list of streets from the system.

func (*Business) QueryByID

func (b *Business) QueryByID(ctx context.Context, streetID uuid.UUID) (Street, error)

QueryByID finds the street by the specified ID.

func (*Business) Update

func (b *Business) Update(ctx context.Context, str Street, us UpdateStreet) (Street, error)

Update modifies data about a street.

type NewStreet

type NewStreet struct {
	CityID     uuid.UUID
	Line1      string
	Line2      string
	PostalCode string
}

func TestNewStreets

func TestNewStreets(n int, cityIDs []uuid.UUID) []NewStreet

TestNewStreets is a helper method for testing.

type QueryFilter

type QueryFilter struct {
	ID         *uuid.UUID
	CityID     *uuid.UUID
	Line1      *string
	Line2      *string
	PostalCode *string
}

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, street Street) error
	Update(ctx context.Context, street Street) error
	Delete(ctx context.Context, street Street) error
	Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]Street, error)
	Count(ctx context.Context, filter QueryFilter) (int, error)
	QueryByID(ctx context.Context, streetID uuid.UUID) (Street, error)
}

Storer interface declares the behavior this package needs to persist and retrieve data.

type Street

type Street struct {
	ID         uuid.UUID
	CityID     uuid.UUID
	Line1      string
	Line2      string
	PostalCode string
}

Street represents information about an individual street.

func TestSeedStreets

func TestSeedStreets(ctx context.Context, n int, cityIDs []uuid.UUID, api *Business) ([]Street, error)

TestSeedStreets is a helper method for testing.

type UpdateStreet

type UpdateStreet struct {
	CityID     *uuid.UUID
	Line1      *string
	Line2      *string
	PostalCode *string
}

Directories

Path Synopsis
stores

Jump to

Keyboard shortcuts

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