teal

package module
v0.0.0-...-510a38a Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDoesNotExist = errors.New("the item does not exist")
	ErrNoRows       = errors.New("no items found")

	ErrDuplicateUsername = errors.New("username already exists")

	ErrNoAuthHeader  = errors.New("no authentication headers")
	ErrInvalidCreds  = errors.New("invalid credentials")
	ErrAPIKeyExpired = errors.New("api key expired")
)

Functions

func ValidateFilters

func ValidateFilters(v *validator.Validator, f Filters)

Types

type Author

type Author struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

func (Author) String

func (a Author) String() string

func (*Author) Validate

func (a *Author) Validate(v *validator.Validator)

type Book

type Book struct {
	ID         int64    `json:"id" db:"id"`
	Title      string   `json:"title" db:"title"`
	Author     []string `json:"author"`
	ISBN       string   `json:"isbn" db:"isbn"`
	NumOfPages int      `json:"num_of_pages" db:"numofpages"`
	Rating     int      `json:"rating" db:"rating"`
	State      string   `json:"state" db:"state,type:state"`

	Description NullString `json:"description,omitempty"`
	Notes       NullString `json:"notes,omitempty"`
	Review      NullString `json:"review,omitempty"`
	Series      NullString `json:"series,omitempty"`
	Genre       []string   `json:"genre,omitempty"`
	Tag         []string   `json:"tag,omitempty"`

	DateCompleted sql.NullTime `json:"-" db:"datecompleted"`

	DateAdded   sql.NullTime `json:"-" db:"dateadded"`
	DateUpdated sql.NullTime `json:"-" db:"dateupdated"`
}

func (Book) String

func (b Book) String() string

func (*Book) Validate

func (b *Book) Validate(v *validator.Validator)

type BookFilters

type BookFilters struct {
	Title  string
	Author string
	Genre  string
	Tag    string
	Series string
	Filters
}

type Category

type Category struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Books       []Book `json:"books,omitempty"`
	DateAdded   string `json:"-"`
	DateUpdated string `json:"-"`
}

type CategoryService

type CategoryService interface {
	GetCategories() ([]*Category, error)
	GetCategory(id int) (*Category, error)
	CreateCategory(b *Category) error
	UpdateCategory(id int) error
	DeleteCategory(id int) error
}

type Filters

type Filters struct {
	AfterId      int
	PageSize     int
	Sort         string
	SortSafeList []string
}

func (Filters) SortColumn

func (f Filters) SortColumn() string

func (Filters) SortDirection

func (f Filters) SortDirection() string

type Genre

type Genre struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	DateAdded   string `json:"-"`
	DateUpdated string `json:"-"`
}

func (*Genre) Validate

func (g *Genre) Validate(v *validator.Validator)

type InputUser

type InputUser struct {
	Name     string
	Username string
	Password string
	Role     string
}

Destination struct for POST user requests

func (*InputUser) Validate

func (u *InputUser) Validate(v *validator.Validator)

type NullString

type NullString struct {
	sql.NullString
}

func (NullString) MarshalJSON

func (n NullString) MarshalJSON() ([]byte, error)

func (NullString) Split

func (n NullString) Split() []string

func (NullString) UnmarshalJSON

func (n NullString) UnmarshalJSON(data []byte) error

type Series

type Series struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	DateAdded   string `json:"-"`
	DateUpdated string `json:"-"`
}

func (*Series) Validate

func (s *Series) Validate(v *validator.Validator)

type Tag

type Tag struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	DateAdded   string `json:"-"`
	DateUpdated string `json:"-"`
}

func (*Tag) Validate

func (t *Tag) Validate(v *validator.Validator)

type User

type User struct {
	ID             int64        `json:"id"`
	Name           string       `json:"name"`
	Username       string       `json:"username"`
	HashedPassword []byte       `json:"-"`
	Role           string       `json:"role" db:"type:role"`
	LastLogin      sql.NullTime `json:"-"`
	DateAdded      time.Time    `json:"-"`
}

func (*User) PasswordMatches

func (u *User) PasswordMatches(text string) (bool, error)

func (*User) SetPassword

func (u *User) SetPassword(text string) error

func (User) String

func (u User) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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