database

package
v0.0.0-...-682d43e Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryHeadMax   = 8
	DatetimeFormat = "2006-01-02 15:04:05"
)

Variables

View Source
var (
	ErrDatabase = trackerr.Checkpoint("Database error")

	ErrCreating  = trackerr.Track("Failed to create database or tables")
	ErrPreparing = trackerr.Track("Failed to prepare database query or statement")
	ErrInserting = trackerr.Track("Failed to execute data insert into database")
	ErrQuerying  = trackerr.Track("Failed to execute query on database")
	ErrParsing   = trackerr.Track("Failed to read or parse database results")
	ErrPrinting  = trackerr.Track("Failed to print rows from database")
	ErrClosed    = trackerr.Track("Can't execute requests on a closed database")

	ErrCSVFile = trackerr.Track("Error handling CSV file")
)

Functions

func InsertMetadataFromCSV

func InsertMetadataFromCSV(db PlatosPizzaDatabase, filename string) error

func InsertOrderDetailsFromCSV

func InsertOrderDetailsFromCSV(db PlatosPizzaDatabase, filename string) error

func InsertOrdersFromCSV

func InsertOrdersFromCSV(db PlatosPizzaDatabase, filename string) error

func InsertPizzaTypesFromCSV

func InsertPizzaTypesFromCSV(db PlatosPizzaDatabase, filename string) error

func InsertPizzasFromCSV

func InsertPizzasFromCSV(db PlatosPizzaDatabase, filename string) error

func Print

func Print(db PlatosPizzaDatabase) error

func PrintMetadata

func PrintMetadata(entries []MetadataEntry)

func PrintOrderDetails

func PrintOrderDetails(orderDetails []OrderDetail)

func PrintOrders

func PrintOrders(orders []Order)

func PrintPizzaTypes

func PrintPizzaTypes(pizzaTypes []PizzaType)

func PrintPizzas

func PrintPizzas(pizzas []Pizza)

func QueryPrintMetadata

func QueryPrintMetadata(db PlatosPizzaDatabase) error

func QueryPrintOrderDetails

func QueryPrintOrderDetails(db PlatosPizzaDatabase) error

func QueryPrintOrders

func QueryPrintOrders(db PlatosPizzaDatabase) error

func QueryPrintPizzaTypes

func QueryPrintPizzaTypes(db PlatosPizzaDatabase) error

func QueryPrintPizzas

func QueryPrintPizzas(db PlatosPizzaDatabase) error

Types

type MetadataEntry

type MetadataEntry struct {
	Table       string
	Field       string
	Description string
}

type Order

type Order struct {
	// Unique identifier for each order placed by a table
	Id int

	// Date & time the order was placed
	// (entered into the system prior to cooking & serving)
	Datetime time.Time
}

Order represents an order of pizzas, one or many pizzas per order

type OrderDetail

type OrderDetail struct {
	// Unique identifier for each pizza placed within each order
	// (pizzas of the same type and size are kept in the same row, and the quantity increases)
	Id int

	// Foreign key that ties the details in each order to the order itself
	OrderId int

	// Foreign key that ties the pizza ordered to its details, like size and price
	PizzaId string

	// Quantity ordered for each pizza of the same type and size
	Quantity int
}

OrderDetail represents a specific pizza type order, one or more pizzas, within an order

type Pizza

type Pizza struct {
	// Unique identifier for each pizza (constituted by its type and size)
	Id string

	// Foreign key that ties each pizza to its broader pizza type
	TypeId string

	// Size of the pizza (Small, Medium, Large, X Large, or XX Large)
	Size string

	// Price of the pizza in USD
	Price float64
}

type PizzaType

type PizzaType struct {
	// Unique identifier for each pizza type
	Id string

	// Name of the pizza as shown in the menu
	Name string

	// Category that the pizza fall under in the menu
	// (Classic, Chicken, Supreme, or Veggie)
	Category string

	// Comma-delimited ingredients used in the pizza as shown in the menu
	// (they all include Mozzarella Cheese, even if not specified; and they all
	// include Tomato Sauce, unless another sauce is specified)
	Ingredients string
}

type PlatosPizzaDatabase

type PlatosPizzaDatabase interface {
	InsertMetadata(...MetadataEntry) error
	InsertOrders(...Order) error
	InsertOrderDetails(...OrderDetail) error
	InsertPizzas(...Pizza) error
	InsertPizzaTypes(...PizzaType) error

	AllMetadata() ([]MetadataEntry, error)
	HeadOrders() ([]Order, error)
	HeadOrderDetails() ([]OrderDetail, error)
	HeadPizzas() ([]Pizza, error)
	HeadPizzaTypes() ([]PizzaType, error)

	Close()
}

PlatosPizzaDatabase represents an interface to a database of orders, pizzas, and information useful for analysing Plato's Pizzeria customer buying habits.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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