model

package
v0.0.0-...-c74eed5 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package model contains our API models

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Product

type Product struct {
	ID    int     `json:"id"`
	Name  string  `json:"name"`
	Price float64 `json:"price"`
}

Product represents products

func GetMany

func GetMany(db *sql.DB, start, count int) ([]Product, error)

GetMany fetches a list of products

func (*Product) AddTestData

func (p *Product) AddTestData(db *sql.DB, count int) error

AddTestData is used to add one or more records into the table for testing.

func (*Product) ClearTable

func (p *Product) ClearTable(db *sql.DB) error

ClearTable to clean the table up.

func (*Product) Delete

func (p *Product) Delete(db *sql.DB) error

Delete deletes one product by id

func (*Product) EnsureTableExists

func (p *Product) EnsureTableExists(db *sql.DB) error

EnsureTableExists makes sure that the table we need for testing is available.

func (*Product) Get

func (p *Product) Get(db *sql.DB) error

Get gets one product by id

func (*Product) Post

func (p *Product) Post(db *sql.DB) error

Post creates a new product

func (*Product) Put

func (p *Product) Put(db *sql.DB) error

Put updates one product by id

Jump to

Keyboard shortcuts

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