item

package
v0.0.0-...-9f32554 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteItem

func DeleteItem(dbc *sqlx.DB, itemID, listID int) error

DeleteItem deletes a row in the item table based off of item_id.

func UpdateItem

func UpdateItem(dbc *sqlx.DB, r Item) error

UpdateItem updates a row in the item table based off of item_id and list_id. The only fields able to be updated are the name and quantity field.

Types

type Item

type Item struct {
	ID       int       `json:"id" db:"item_id"`
	ListID   int       `json:"listID" db:"list_id"`
	Name     string    `json:"name" db:"name"`
	Quantity int       `json:"quantity" db:"quantity"`
	Created  time.Time `json:"created" db:"created"`
	Modified time.Time `json:"modified" db:"modified"`
}

Item is a type that contains the proper struct tags for both a JSON and Postgres representation of an item.

func CreateItem

func CreateItem(dbc *sqlx.DB, r Item) (Item, error)

CreateItem inserts a new row into the item table.

func SelectItem

func SelectItem(dbc *sqlx.DB, iid, lid int) (Item, error)

SelectItem selects a single row from the item table based off given list_id and item_id.

func SelectItems

func SelectItems(dbc *sqlx.DB, listID int) ([]Item, error)

SelectItems selects all appropriate rows from the item table given a list_id.

Jump to

Keyboard shortcuts

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