data

package
v0.0.0-...-de70ca6 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNotFound is returned when the no records where matched by the query
	ErrNotFound = errors.New("not found")
)

Functions

func Save

func Save(ctx context.Context, cfg Config, in *Person) (int, error)

Save will save the supplied person and return the ID of the newly created person or an error. Errors returned are caused by the underlying database or our connection to it.

Types

type Config

type Config interface {
	// Logger returns a reference to the logger
	Logger() logging.Logger

	// DataDSN returns the data source name
	DataDSN() string
}

Config is the configuration for the data package

type Person

type Person struct {
	// ID is the unique ID for this person
	ID int
	// FullName is the name of this person
	FullName string
	// Phone is the phone for this person
	Phone string
	// Currency is the currency this person has paid in
	Currency string
	// Price is the amount (in the above currency) paid by this person
	Price float64
}

Person is the data transfer object (DTO) for this package

func Load

func Load(ctx context.Context, cfg Config, ID int) (*Person, error)

Load will attempt to load and return a person. It will return ErrNotFound when the requested person does not exist. Any other errors returned are caused by the underlying database or our connection to it.

func LoadAll

func LoadAll(ctx context.Context, cfg Config) ([]*Person, error)

LoadAll will attempt to load all people in the database It will return ErrNotFound when there are not people in the database Any other errors returned are caused by the underlying database or our connection to it.

Jump to

Keyboard shortcuts

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