models

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2016 License: MIT Imports: 17 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("No record found matching supplied criteria")

ErrNotFound represents the error when a database record cannot be found matching the criteria specified by the caller

Functions

This section is empty.

Types

type Note

type Note struct {
	ID         int64
	RecipeID   int64
	Note       string
	CreatedAt  time.Time
	ModifiedAt time.Time
}

Note represents an individual comment (or note) on a recipe

func (*Note) Create

func (note *Note) Create() error

Create stores the note in the database as a new record using a dedicated transation that is committed if there are not errors.

func (*Note) CreateTx

func (note *Note) CreateTx(tx *sql.Tx) error

CreateTx stores the note in the database as a new record using the specified transaction.

type Notes

type Notes []Note

Notes represents a collection of Note objects

func (*Notes) List

func (notes *Notes) List(recipeID int64) error

List retrieces all notes associated with the recipe with the specified id.

type Recipe

type Recipe struct {
	ID          int64
	Name        string
	Description string
	Ingredients string
	Directions  string
	Image       string
	Tags        Tags
}

Recipe is the primary model class for recipe storage and retrieval

func (*Recipe) Create

func (recipe *Recipe) Create() error

Create stores the recipe in the database as a new record using a dedicated transation that is committed if there are not errors.

func (*Recipe) CreateTx

func (recipe *Recipe) CreateTx(tx *sql.Tx) error

CreateTx stores the recipe in the database as a new record using the specified transaction.

func (*Recipe) Delete

func (recipe *Recipe) Delete() error

func (*Recipe) DeleteTx

func (recipe *Recipe) DeleteTx(tx *sql.Tx) error

func (*Recipe) Read

func (recipe *Recipe) Read() error

Read retrieves the information about the recipe from the database, if found. If no recipe exists with the specified ID, a NoRecordFound error is returned.

func (*Recipe) Update

func (recipe *Recipe) Update() error

Update stores the specified recipe in the database by updating the existing record with the sepcified id using a dedicated transation that is committed if there are not errors.

func (*Recipe) UpdateTx

func (recipe *Recipe) UpdateTx(tx *sql.Tx) error

UpdateTx stores the specified recipe in the database by updating the existing record with the sepcified id using the specified transaction.

type RecipeImage

type RecipeImage struct {
	RecipeID     int64
	URL          string
	ThumbnailURL string
}

func (*RecipeImage) Create

func (img *RecipeImage) Create(name string, data []byte) error

type RecipeImages

type RecipeImages []RecipeImage

func (*RecipeImages) List

func (imgs *RecipeImages) List(recipeID int64) error

type Recipes

type Recipes []Recipe

Recipes represents a collection of Recipe objects

func (*Recipes) Find

func (recipes *Recipes) Find(search string, page int, count int) (int, error)

func (*Recipes) List

func (recipes *Recipes) List(page int, count int) (int, error)

type Tag

type Tag string

func (*Tag) Create

func (tag *Tag) Create(recipeID int64) error

func (*Tag) CreateTx

func (tag *Tag) CreateTx(tx *sql.Tx, recipeID int64) error

type Tags

type Tags []Tag

func (*Tags) DeleteAll

func (tags *Tags) DeleteAll(recipeID int64) error

func (*Tags) DeleteAllTx

func (tags *Tags) DeleteAllTx(tx *sql.Tx, recipeID int64) error

func (*Tags) List

func (tags *Tags) List(recipeID int64) error

Jump to

Keyboard shortcuts

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