models

package
v0.0.0-...-8530ca8 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRecord           = errors.New("models: no matching record found")
	ErrInvalidCredentials = errors.New("models: invalid credentials")
	ErrDuplicateEmail     = errors.New("models: duplicate email")
)

Functions

This section is empty.

Types

type Snippet

type Snippet struct {
	ID      int       `json:"id"`
	Title   string    `json:"title"`
	Content string    `json:"content"`
	Created time.Time `json:"created"`
	Expires time.Time `json:"expires"`
}

func (*Snippet) AfterFind

func (snippet *Snippet) AfterFind()

func (*Snippet) GetID

func (snippet *Snippet) GetID() int

func (*Snippet) SetID

func (snippet *Snippet) SetID(id int)

type Snippets

type Snippets struct {
	*hare.Table
}

func NewSnippets

func NewSnippets(db *hare.Database) (*Snippets, error)

func (*Snippets) Get

func (snippets *Snippets) Get(id int) (*Snippet, error)

func (*Snippets) Insert

func (snippets *Snippets) Insert(title, content, expires string) (int, error)

func (*Snippets) Latest

func (snippets *Snippets) Latest() ([]*Snippet, error)

This will return the 10 most recently created snippets.

func (*Snippets) Query

func (snippets *Snippets) Query(queryFn func(snippet Snippet) bool, limit int) ([]Snippet, error)

type User

type User struct {
	ID             int       `json:"id"`
	Name           string    `json:"name"`
	Email          string    `json:"email"`
	HashedPassword []byte    `json:"hashed_password"`
	Created        time.Time `json:"created"`
	Active         bool      `json:"active"`
}

func (*User) AfterFind

func (user *User) AfterFind()

func (*User) GetID

func (user *User) GetID() int

func (*User) SetID

func (user *User) SetID(id int)

type Users

type Users struct {
	*hare.Table
}

func NewUsers

func NewUsers(db *hare.Database) (*Users, error)

func (*Users) Authenticate

func (users *Users) Authenticate(email, password string) (int, error)

func (*Users) Insert

func (users *Users) Insert(name, email, password string) error

func (*Users) Query

func (users *Users) Query(queryFn func(user User) bool, limit int) ([]User, error)

Jump to

Keyboard shortcuts

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