db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2018 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize(connectionString string) *sqlx.DB

Initialize DB.

Types

type MenuCategory struct {
	ID uint64 `json:"id" db:"id"`
	// Name of the menu category.
	// required: true
	Name string `json:"name" db:"name"`
	// Order of this category in categories list.
	// required: true
	Order     uint64    `json:"order" db:"order"`
	CreatedAt time.Time `json:"-" db:"created_at"`
	UpdatedAt time.Time `json:"-" db:"updated_at"`
}

MenuCategory model for menu categories.

swagger:model

func (MenuCategory) Find(db *sqlx.DB, id uint64) (*MenuCategory, error)

Find returns MenuItem object with specified ID.

func (MenuCategory) GetAll(db *sqlx.DB) (*[]MenuCategory, error)

GetAll returns list menu categories sorted by order.

func (menuCategory *MenuCategory) Insert(db *sqlx.DB) error

Insert adds new category.

func (menuCategory *MenuCategory) Update(db *sqlx.DB) error

Update menu category object in DB.

type MenuItem struct {
	ID uint64 `json:"id" db:"id"`
	// Name of the menu item.
	// required: true
	Name string `json:"name" db:"name"`
	// Description of the menu item.
	// required: true
	Description string `json:"description" db:"description"`
	// Price of the menu item in Bahrain Dinars.
	// required: true
	Price float32 `json:"price" db:"price"`
	// Category of the menu item.
	// required: true
	CategoryID uint64 `json:"category_id" db:"category_id"`
	// Image URL for the menu item.
	// required: true
	ImageURL string `json:"image_url" db:"image_url"`
	// Active flag for the menu item.
	// required: true
	Active    bool      `json:"active" db:"active"`
	CreatedAt time.Time `json:"-" db:"created_at"`
	UpdatedAt time.Time `json:"-" db:"updated_at"`
}

MenuItem model for menu.

swagger:model

func (MenuItem) Destroy(db *sqlx.DB, id uint64) error

Destroy menu item with specified ID.

func (MenuItem) Find(db *sqlx.DB, id uint64) (*MenuItem, error)

Find returns MenuItem object with specified ID.

func (MenuItem) GetAll(db *sqlx.DB) (*[]MenuItem, error)

GetAll returns list of all menu items.

func (MenuItem) GetByCategory(db *sqlx.DB, categoryID uint64) (*[]MenuItem, error)

GetByCategory returns list of all menu items in given category.

func (MenuItem) GetCategories(db *sqlx.DB) ([]string, error)

GetCategories returns list of unique menu categories.

func (menuItem *MenuItem) Insert(db *sqlx.DB) error

Insert adds new menu item.

func (menuItem *MenuItem) Update(db *sqlx.DB) error

Update menu item object in DB.

type Reservation

type Reservation struct {
	ID uint64 `json:"id" db:"id"`
	// ID of table, associated with reservation.
	// required: true
	TableID uint64 `json:"table_id" db:"table_id"`
	// Number of people to seat for reservation.
	// required: true
	Guests int64 `json:"guests" db:"guests"`
	// Email of the client.
	// required: true
	Email string `json:"email" db:"email"`
	// Phone of the client.
	// required: true
	Phone string `json:"phone" db:"phone"`
	State State  `json:"state" db:"state"`
	// Full Name of the client.
	// required: true
	FullName string `json:"full_name" db:"full_name"`
	// Time of the reservation.
	// required: true
	Time time.Time `json:"time" db:"time"`
	// Duration of the reservation.
	// required: truee
	Duration  time.Duration `json:"duration" db:"duration"`
	CreatedAt time.Time     `json:"-" db:"created_at"`
	UpdatedAt time.Time     `json:"-" db:"updated_at"`
}

Reservation model for table reservation proccess.

swagger:model

func (Reservation) Destroy

func (Reservation) Destroy(db *sqlx.DB, id uint64) error

Destroy reservation with specified ID.

func (Reservation) Find

func (Reservation) Find(db *sqlx.DB, id uint64) (*Reservation, error)

Find returns Reservation's object with specified ID.

func (Reservation) GetAll

func (Reservation) GetAll(db *sqlx.DB) (*[]Reservation, error)

GetAll returns list of all reservations.

func (*Reservation) GetStopTime

func (reservation *Reservation) GetStopTime() time.Time

GetStopTime calculates finish time of reservations.

func (Reservation) GetUpcoming

func (Reservation) GetUpcoming(db *sqlx.DB) (*[]Reservation, error)

GetUpcoming returns upcoming reservations.

func (*Reservation) Insert

func (reservation *Reservation) Insert(db *sqlx.DB) error

Insert adds new reservation.

func (*Reservation) Update

func (reservation *Reservation) Update(db *sqlx.DB) error

Update puts new values for reservation row fields.

func (*Reservation) Validate

func (reservation *Reservation) Validate(db *sqlx.DB) error

Validate validates all conditions to create new table reservation record.

type State

type State string

State is string representation of reservation state. swagger:strfmt state

const (
	// StateCreated returns state string of created reservation.
	StateCreated State = "created"
	// StateApproved returns state string of approved reservation.
	StateApproved State = "approved"
	// StateCancelled returns state string of cancelled reservation.
	StateCancelled State = "cancelled"
)

type Table

type Table struct {
	ID uint64 `json:"id" db:"id"`
	// Number of places to seat.
	// required: true
	Places int64 `json:"places" db:"places"`
	// Description of the table.
	// required: true
	Description string `json:"description" db:"description"`
	// Active flag for the table.
	// required: true
	Active    bool      `json:"active" db:"active"`
	CreatedAt time.Time `json:"-" db:"created_at"`
	UpdatedAt time.Time `json:"-" db:"updated_at"`
}

Table represents restaurant table.

swagger:parameters model

func (Table) Destroy

func (Table) Destroy(db *sqlx.DB, id uint64) error

Destroy table with specified ID.

func (Table) Find

func (Table) Find(db *sqlx.DB, id uint64) (*Table, error)

Find returns Tables object with specified ID.

func (Table) GetAll

func (Table) GetAll(db *sqlx.DB) (*[]Table, error)

GetAll returns list of all tables.

func (*Table) Insert

func (table *Table) Insert(db *sqlx.DB) error

Insert adds new table.

func (*Table) Update

func (table *Table) Update(db *sqlx.DB) error

Update table object in DB.

Jump to

Keyboard shortcuts

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