db

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Charge

type Charge struct {
	Description string  `json:"description"`
	Amount      float32 `json:"amount"`
}

Charge represents a charge for a damaged/missing device

type Charges

type Charges []Charge

Charges is a list of Charges

func (Charges) Marshal

func (charges Charges) Marshal() string

Marshal marshals charges to the inventory database format

func (Charges) Total

func (charges Charges) Total() float32

Total returns the total charge amount

type DB

type DB interface {
	//Begin returns a transaction for the database or an error if one occurred
	Begin() (*sql.Tx, error)

	//CreateCharge creates a charge in the database with the given info and returns the ID of the charges or an error if one occurred
	CreateCharge(tx *sql.Tx, charges Charges, inventoryNumber, user, notes string) (id int64, err error)

	//ReadDevice returns the Device with with the given bagTag or an error if one occurred
	ReadDevice(tx *sql.Tx, bagTag string) (*Device, error)

	//UpdateDevice updates the given Device by the given username or returns an error if one occurred
	UpdateDevice(tx *sql.Tx, device *Device, username string) error
}

DB represents a database

type Device

type Device struct {
	ID              int64  `json:"id"`
	InventoryNumber string `json:"inventory_number"`
	SerialNumber    string `json:"serial_number"`
	BagTag          string `json:"bag_tag"`
	Status          string `json:"status"`
	Model           string `json:"model"`
	User            string `json:"user"`
	Notes           string `json:"notes"`
}

Device represents a device in the inventory database

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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