db

package
Version: v0.0.0-...-1607f05 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HOST = "localhost"
	PORT = 5432
)

Variables

View Source
var ErrNotFound = fmt.Errorf("no matching record")

ErrNotFound indicates requested entity does not exist

Functions

This section is empty.

Types

type Database

type Database struct {
	Conn *sql.DB
}

func Initialize

func Initialize(username, password, database string) (Database, error)

func (Database) AddItem

func (db Database) AddItem(item *Item) error

func (Database) DeleteItem

func (db Database) DeleteItem(itemId int) error

func (Database) Get1000Items

func (db Database) Get1000Items() (*ItemList, error)

func (Database) GetItemById

func (db Database) GetItemById(itemId int) (Item, error)

func (Database) UpdateItem

func (db Database) UpdateItem(itemId int, itemData Item) (Item, error)

type Item

type Item struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	CreatedAt   string `json:"created_at"`
}

type ItemList

type ItemList struct {
	Items []Item `json:"items"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL