sql

package
v0.0.0-...-155bba5 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ShortForm = "02/01/2006"

Variables

View Source
var DBc *gorm.DB

DBc connection to our local DB

Functions

func DBInit

func DBInit(DbType string, DbPath string)

DBInit initialize database connection and setups GORM

func DBPreload

func DBPreload()

DBPreload will load db with preload data TODO: Make sure we load only data which is needed when it's needed.

func GetCustomerByName

func GetCustomerByName(customerName string, customer *Customer) error

GetCustomerByName return customer if exists

func GetProjectByID

func GetProjectByID(projectID uint, project *Project) error

GetProjectByID searchs for a project by it's ID and customer's ID to whitch it belongs

func GetProjectByName

func GetProjectByName(customerName string, projectName string, project *Project) error

GetProjectByName searchs for a project by it's name and customer's name to whitch it belongs

Types

type Customer

type Customer struct {
	gorm.Model
	Name string `gorm:"unique;not null"`
	Rate uint

	Projects []Project `gorm:"foreignkey:CustomerID"`

	ContactName  string
	ContactEmail string
}

Customer definitions with it's getters

func (Customer) GetContactEmail

func (c Customer) GetContactEmail() string

GetContactEmail getter for customer email

func (Customer) GetContactName

func (c Customer) GetContactName() string

GetContactName getter for customer contact

func (Customer) GetID

func (c Customer) GetID() uint

GetID getter for customer ID

func (Customer) GetName

func (c Customer) GetName() string

GetName getter for customer name

func (Customer) GetRate

func (c Customer) GetRate() uint

GetRate getter for customer rate

type Entry

type Entry struct {
	gorm.Model
	Name      string
	Duration  int64
	StartDate int64
	EndDate   int64
	Desc      string
	Billable  bool

	ProjectID uint

	Tags []*Tag `gorm:"many2many:entry_tags;" json:"-"`
}

Entry definitions with it's Byters

func (Entry) GetCustomerName

func (e Entry) GetCustomerName() string

GetCustomerName for instance of a project

func (Entry) GetDesc

func (e Entry) GetDesc() string

GetDesc getter for entry

func (Entry) GetDuration

func (e Entry) GetDuration() int64

GetDuration getter for entry

func (Entry) GetDurationString

func (e Entry) GetDurationString() string

GetDurationString gets duretion converted to string for entry

func (Entry) GetID

func (e Entry) GetID() uint

GetID getter for entry ID

func (Entry) GetName

func (e Entry) GetName() string

GetName getter for entry Name

func (Entry) GetProjectName

func (e Entry) GetProjectName() string

GetProjectName for instance of a project

func (Entry) GetSDate

func (e Entry) GetSDate() int64

GetSDate getter for entry

func (Entry) GetSDateString

func (e Entry) GetSDateString() string

func (Entry) MarshalJSON

func (e Entry) MarshalJSON() ([]byte, error)

type Project

type Project struct {
	gorm.Model
	Name     string
	Estimate int64
	Finished bool `gorm:"default:false"`

	CustomerID uint `json:"-"`

	Entries []Entry `gorm:"foreignkey:ProjectID"`
}

Project definitions with it's getters

func (Project) GetCustomerName

func (p Project) GetCustomerName() string

GetCustomerName for instance of a project

func (Project) GetCustomerRate

func (p Project) GetCustomerRate() uint

GetCustomerRate for instance of a project

func (Project) GetEstimate

func (p Project) GetEstimate() int64

GetEstimate getter for project Planned hours

func (Project) GetEstimateString

func (p Project) GetEstimateString() string

GetDurationString gets duretion converted to string for entry

func (Project) GetFinished

func (p Project) GetFinished() bool

Get Finished flag.

func (Project) GetID

func (p Project) GetID() uint

GetID getter for project ID

func (Project) GetName

func (p Project) GetName() string

GetName getter for project Name

func (Project) GetWorkLogged

func (p Project) GetWorkLogged() int64

func (Project) GetWorkLoggedString

func (p Project) GetWorkLoggedString() string

func (Project) MarshalJSON

func (p Project) MarshalJSON() ([]byte, error)

type Tag

type Tag struct {
	gorm.Model `json:"-"`
	Name       string `gorm:"unique"`

	Entries []*Entry `gorm:"many2many:entry_tags;"`
}

Jump to

Keyboard shortcuts

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