dao

package
v0.0.0-...-82d3620 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseDatastore

type BaseDatastore interface {
	ListMatch(input ListMatchInput) (*[]Match, error)
	CreateMatch(input CreateMatchInput) (*Match, error)
	ReadMatch(input ReadMatchInput) (*Match, error)
	UpdateMatch(input UpdateMatchInput) (*Match, error)
	DeleteMatch(input DeleteMatchInput) error
}

BaseDatastore provides the basic datastore methods

type CreateMatchInput

type CreateMatchInput struct {
	ID        uuid.UUID
	AuthID    uuid.UUID
	UserOne   uuid.UUID
	UserTwo   uuid.UUID
	MatchedOn time.Time
}

CreateMatchInput encapsulates the information required to create a single match in the datastore

type DAO

type DAO struct {
	DB *sql.DB
}

DAO encapsulates access to the datastore

func Init

func Init(config *util.Config) (*DAO, error)

Init opens the datastore connection, returning a DAO

func (*DAO) CreateMatch

func (dao *DAO) CreateMatch(input CreateMatchInput) (*Match, error)

CreateMatch creates a new match in the datastore, returning the newly created match

func (*DAO) DeleteMatch

func (dao *DAO) DeleteMatch(input DeleteMatchInput) error

DeleteMatch deletes a match in the datastore

func (*DAO) ListMatch

func (dao *DAO) ListMatch(input ListMatchInput) (*[]Match, error)

ListMatch returns a list containing every match in the datastore for a given ID

func (*DAO) ReadMatch

func (dao *DAO) ReadMatch(input ReadMatchInput) (*Match, error)

ReadMatch returns the match in the datastore for a given ID

func (*DAO) UpdateMatch

func (dao *DAO) UpdateMatch(input UpdateMatchInput) (*Match, error)

UpdateMatch updates a match in the datastore, returning the newly updated match

type Datastore

type Datastore interface {
	BaseDatastore
}

Datastore provides the interface adopted by the DAO, allowing for mocking

type DeleteMatchInput

type DeleteMatchInput struct {
	ID uuid.UUID
}

DeleteMatchInput encapsulates the information required to delete a single match in the datastore

type ErrMatchNotFound

type ErrMatchNotFound string

ErrMatchNotFound is returned when a match for the provided ID was not found

func (ErrMatchNotFound) Error

func (e ErrMatchNotFound) Error() string

type ListMatchInput

type ListMatchInput struct {
	AuthID uuid.UUID
}

ListMatchInput encapsulates the information required to read a match list in the datastore

type Match

type Match struct {
	ID        uuid.UUID
	CreatedBy uuid.UUID
	UserOne   uuid.UUID
	UserTwo   uuid.UUID
	MatchedOn time.Time
}

Match encapsulates the object stored in the datastore

type ReadMatchInput

type ReadMatchInput struct {
	ID uuid.UUID
}

ReadMatchInput encapsulates the information required to read a single match in the datastore

type UpdateMatchInput

type UpdateMatchInput struct {
	ID        uuid.UUID
	UserOne   uuid.UUID
	UserTwo   uuid.UUID
	MatchedOn time.Time
}

UpdateMatchInput encapsulates the information required to update a single match in the datastore

Jump to

Keyboard shortcuts

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