dal

package
v0.0.0-...-63ec63b Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MockupDB = `` /* 404-byte string literal not displayed */

Mockup database for testing

Variables

This section is empty.

Functions

func AddPurchase

func AddPurchase(db *sqlx.DB, purchase *Purchase) error

AddPurchase adds a new a purchase to the database.

func DeletePurchase

func DeletePurchase(db *sqlx.DB, byID uint64) error

DeletePurchase removes a purchase from the database.

func ValidatePurchase

func ValidatePurchase(purchase *Purchase) (ok bool, errs []error)

ValidatePurchase validates a purchase before database insertion

Types

type Purchase

type Purchase struct {
	ID         uint64    `json:"id"`
	Name       string    `json:"name"`
	Cost       float64   `json:"cost"`
	TimeBought time.Time `json:"time_bought" db:"time_bought"`
}

Purchase is the primary dal for an item purchased.

func GetPurchase

func GetPurchase(db *sqlx.DB, byID uint64) (*Purchase, error)

GetPurchase retrieves a purchase by its ID.

func GetPurchases

func GetPurchases(db *sqlx.DB) ([]Purchase, error)

GetPurchases lists all purchases from the database.

func GetPurchasesAfterLastMarker

func GetPurchasesAfterLastMarker(db *sqlx.DB) ([]Purchase, error)

GetPurchasesAfterLastMarker lists all purchases from the database made after the last marker date, the one one month before the current marker date.

Jump to

Keyboard shortcuts

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