party

package
v0.0.0-...-21167b7 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package party contains party-related CRUD functionality

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is used when a specific Party is requested but does not exist.
	ErrNotFound = errors.New("not found")

	// ErrInvalidID occurs when an ID is not in a valid form.
	ErrInvalidID = errors.New("ID is not in its proper form")

	// ErrForbidden occurs when a user tries to do something that is forbidden to them according to our access control policies.
	ErrForbidden = errors.New("attempted action is not allowed")
)

Functions

This section is empty.

Types

type Info

type Info struct {
	ID          string    `db:"party_id"`
	Name        string    `db:"name"`
	Location    string    `db:"location"`
	LfPlayers   int       `db:"lf_players"`
	LfGM        int       `db:"lf_gm"`
	Description string    `db:"description"`
	DateCreated time.Time `db:"date_created"`
	DateUpdated time.Time `db:"date_updated"`
}

Info represents a single meet.

type NewParty

type NewParty struct {
	Name        string `json:"name" validate:"required,max=255"`
	Description string `json:"description" validate:"required,min=50,max=1000"`
	Location    string `json:"location" validate:"required,max=255"`
	LfPlayers   int    `json:"lf_players,string" validate:"required_without=LfGM,gte=0,lte=10"`
	LfGM        int    `json:"lf_gm,string" validate:"required_without=LfPlayers,gte=0,lte=10"`
}

NewParty describes the required data for creating a new party.

type Party

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

Party manages the set of API's for party access.

func New

func New(log *log.Logger, db *sqlx.DB) Party

New constructs a Party for api access.

func (Party) Create

func (p Party) Create(ctx context.Context, traceID string, np NewParty, now time.Time) (Info, error)

Create adds a Party to the database. It returns the created Party with fields like ID and DateCreated populated.

func (Party) Query

func (p Party) Query(ctx context.Context, traceID string, pageNumber int, rowsPerPage int) ([]*Info, error)

Query gets all parties from the database.

func (Party) QueryByID

func (p Party) QueryByID(ctx context.Context, traceID string, partyID string) (*Info, error)

QueryByID finds the party identified by a given ID.

Jump to

Keyboard shortcuts

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