titlebus

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          = "title_id"
	OrderByName        = "name"
	OrderByDescription = "description"
)

Variables

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

Set of error variables for CRUD operations.

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

Functions

This section is empty.

Types

type Business

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

func NewBusiness

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

NewBusiness constructs a new title business API for use.

func (*Business) Count

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

Count returns the total number of titles

func (*Business) Create

func (b *Business) Create(ctx context.Context, nt NewTitle) (Title, error)

Create creates a new title to the system.

func (*Business) Delete

func (b *Business) Delete(ctx context.Context, fs Title) error

Delete removes an title 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) ([]Title, error)

Query returns a list of titles

func (*Business) QueryByID

func (b *Business) QueryByID(ctx context.Context, titleStatusID uuid.UUID) (Title, error)

QueryByID finds the title by the specified ID.

func (*Business) Update

func (b *Business) Update(ctx context.Context, fs Title, ut UpdateTitle) (Title, error)

Update modifies information about an title.

type NewTitle

type NewTitle struct {
	Name        string
	Description string
}

func TestNewTitle

func TestNewTitle(n int) []NewTitle

type QueryFilter

type QueryFilter struct {
	ID          *uuid.UUID
	Name        *string
	Description *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, title Title) error
	Update(ctx context.Context, title Title) error
	Delete(ctx context.Context, title Title) error
	Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]Title, error)
	Count(ctx context.Context, filter QueryFilter) (int, error)
	QueryByID(ctx context.Context, titleID uuid.UUID) (Title, error)
}

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

type Title

type Title struct {
	ID          uuid.UUID
	Name        string
	Description string
}

func TestSeedTitles

func TestSeedTitles(ctx context.Context, n int, api *Business) ([]Title, error)

type UpdateTitle

type UpdateTitle struct {
	Name        *string
	Description *string
}

Directories

Path Synopsis
stores

Jump to

Keyboard shortcuts

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