storage

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PaginationLimit = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	CEP          string     `json:"cep" db:"cep"`
	State        string     `json:"state"  db:"state"`
	City         string     `json:"city" db:"location"`
	Neighborhood string     `json:"neighborhood" db:"neighborhood"`
	Location     string     `json:"location" db:"location"`
	Children     []*Address `json:"children" db:"children"`

	CreatedAt *time.Time `json:"created_at,omitempty,omitempty"  db:"cep"`
	UpdatedAt *time.Time `json:"updated_at,omitempty,omitempty"  db:"cep"`
}

type ListParams

type ListParams struct {
	State      string
	Pagination *Pagination
}

type Pagination

type Pagination struct {
	Limit  int
	Offset int
}

Pagination is passed as a parameter to limit the total of rows.

func NewPagination

func NewPagination(perPage, page int) *Pagination

type Storage

type Storage interface {
	Close()
	Check(ctx context.Context) error

	CreateAddress(ctx context.Context, address *Address) error
	UpdateAddress(ctx context.Context, cep string, updater Updater) error
	GetAddress(ctx context.Context, cep string) (*Address, error)
	ListAddresses(ctx context.Context, params ListParams) ([]*Address, error)
}

type Updater

type Updater func(old *Address) (*Address, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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