models

package
v0.0.0-...-d1d9811 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateEmail = errors.New("models: duplicate email")
View Source
var ErrInvalidCredentials = errors.New("models: invalid credentials")
View Source
var ErrNoRecord = errors.New("models: no matching record found")
View Source
var ErrSumPageCount = errors.New("models: error while querying page count")

Functions

This section is empty.

Types

type Book

type Book struct {
	ID        uint         `json:"id"`
	CreatedAt sql.NullTime `json:"created_at"`
	UpdatedAt sql.NullTime `json:"updated_at"`
	DeletedAt sql.NullTime `json:"deleted_at"`
	Title     string       `json:"title"`
	Author    string       `json:"author"`
	Language  string       `json:"language"`
	Category  string       `json:"category"`
	ISBN10    string       `json:"isbn10"`
	ISBN13    string       `json:"isbn13"`
	PageCount int          `json:"page_count"`
	Rating    int          `json:"rating"`
	Review    string       `json:"review"`
}

Book

type BookModel

type BookModel struct {
	DB *sql.DB
}

func (*BookModel) Get

func (b *BookModel) Get(id int) (*Book, error)

func (*BookModel) Insert

func (b *BookModel) Insert(title string, author string, language string, category string, isbn10 string, isbn13 string, pagecount int, rating int, review string) (int, error)

func (*BookModel) Latest

func (b *BookModel) Latest(limit int) ([]*Book, error)

This will return the 10 most recently created snippets.

func (*BookModel) Search

func (b *BookModel) Search(query string) ([]*Book, error)

func (*BookModel) SumPageCount

func (b *BookModel) SumPageCount() int

type Result

type Result struct {
	Value int
}

type User

type User struct {
	ID             uint      `json:"id"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	DeletedAt      time.Time `json:"deleted_at"`
	Name           string
	Email          string
	HashedPassword []byte
}

type UserModel

type UserModel struct {
	DB *sql.DB
}

func (*UserModel) Authenticate

func (u *UserModel) Authenticate(email, password string) (int, error)

func (*UserModel) Exists

func (u *UserModel) Exists(id int) (bool, error)

func (*UserModel) Insert

func (u *UserModel) Insert(name, email, password string) error

Jump to

Keyboard shortcuts

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