models

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 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 Model added in v0.3.0

type Model struct {
	Recipes *RecipeModel
	Tags    *TagModel
	Notes   *NoteModel
	Images  *RecipeImageModel
	// contains filtered or unexported fields
}

func New added in v0.3.0

func New(cfg *conf.Config) *Model

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

type NoteModel added in v0.3.0

type NoteModel struct {
	*Model
}

func (*NoteModel) Create added in v0.3.0

func (m *NoteModel) Create(note *Note) 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 (*NoteModel) CreateTx added in v0.3.0

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

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

func (*NoteModel) List added in v0.3.0

func (m *NoteModel) List(recipeID int64) (*Notes, error)

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

type Notes

type Notes []Note

Notes represents a collection of Note objects

type Recipe

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

Recipe is the primary model class for recipe storage and retrieval

type RecipeImage

type RecipeImage struct {
	RecipeID     int64
	URL          string
	ThumbnailURL string
}

type RecipeImageModel added in v0.3.0

type RecipeImageModel struct {
	*Model
}

func (*RecipeImageModel) List added in v0.3.0

func (m *RecipeImageModel) List(recipeID int64) (*RecipeImages, error)

func (*RecipeImageModel) Save added in v0.3.0

func (m *RecipeImageModel) Save(recipeID int64, name string, data []byte) error

type RecipeImages

type RecipeImages []RecipeImage

type RecipeModel added in v0.3.0

type RecipeModel struct {
	*Model
}

func (*RecipeModel) Create added in v0.3.0

func (m *RecipeModel) Create(recipe *Recipe) 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 (*RecipeModel) CreateTx added in v0.3.0

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

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

func (*RecipeModel) Delete added in v0.3.0

func (m *RecipeModel) Delete(id int64) error

func (*RecipeModel) DeleteTx added in v0.3.0

func (m *RecipeModel) DeleteTx(id int64, tx *sql.Tx) error

func (*RecipeModel) Find added in v0.3.0

func (m *RecipeModel) Find(search string, page int64, count int64) (*Recipes, int64, error)

func (*RecipeModel) List added in v0.3.0

func (m *RecipeModel) List(page int64, count int64) (*Recipes, int64, error)

func (*RecipeModel) Read added in v0.3.0

func (m *RecipeModel) Read(id int64) (*Recipe, 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 (*RecipeModel) Update added in v0.3.0

func (m *RecipeModel) Update(recipe *Recipe) 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 (*RecipeModel) UpdateTx added in v0.3.0

func (m *RecipeModel) UpdateTx(recipe *Recipe, 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 Recipes

type Recipes []Recipe

Recipes represents a collection of Recipe objects

type TagModel added in v0.3.0

type TagModel struct {
	*Model
}

func (*TagModel) Create added in v0.3.0

func (m *TagModel) Create(recipeID int64, tag string) error

func (*TagModel) CreateTx added in v0.3.0

func (m *TagModel) CreateTx(recipeID int64, tag string, tx *sql.Tx) error

func (*TagModel) DeleteAll added in v0.3.0

func (m *TagModel) DeleteAll(recipeID int64) error

func (*TagModel) DeleteAllTx added in v0.3.0

func (m *TagModel) DeleteAllTx(recipeID int64, tx *sql.Tx) error

func (*TagModel) List added in v0.3.0

func (m *TagModel) List(recipeID int64) (*[]string, error)

Jump to

Keyboard shortcuts

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