models

package
v0.0.0-...-fca878f Latest Latest
Warning

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

Go to latest
Published: May 25, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingRequiredParameters reqd parameter missing
	ErrMissingRequiredParameters = errors.New("missing required parameter")
	// ErrRecordsNotFound list is empty
	ErrRecordsNotFound = errors.New("record(s) not found")
	// ErrRecordNotFound data not exiss
	ErrRecordNotFound = errors.New("record not found")
	// ErrRecordMismatch generated hashkey by name is a mismatch
	ErrRecordMismatch = errors.New("record id/name mismatch")
	// ErrRecordExists data already exiss
	ErrRecordExists = errors.New("record exists")
	// ErrDBTransaction internal storage error
	ErrDBTransaction = errors.New("db storage failed")
)

Functions

This section is empty.

Types

type Building

type Building struct {
	ID             int64           `gorm:"primary_key" json:"id,omitempty"`
	Name           string          `json:"name,omitempty"`
	Address        string          `json:"address,omitempty"`
	CreatedAt      time.Time       `json:"created_at,omitempty"`
	UpdatedAt      time.Time       `json:"updated_at,omitempty"`
	BuildingFloors []BuildingFloor `gorm:"ForeignKey:BuildingID" json:"floors,omitempty"`
}

Building table buildings

func NewBuildingData

func NewBuildingData() *Building

NewBuildingData new instance

func (*Building) AfterCreate

func (q *Building) AfterCreate(dbh *gorm.DB) (err error)

AfterCreate callback after create

func (*Building) AfterDelete

func (q *Building) AfterDelete(dbh *gorm.DB) (err error)

AfterDelete callback after remove

func (*Building) AfterSave

func (q *Building) AfterSave(dbh *gorm.DB) (err error)

AfterSave callback after save

func (*Building) AfterUpdate

func (q *Building) AfterUpdate(dbh *gorm.DB) (err error)

AfterUpdate callback after update

func (*Building) BeforeCreate

func (q *Building) BeforeCreate() (err error)

BeforeCreate callback before create

func (*Building) BeforeDelete

func (q *Building) BeforeDelete() (err error)

BeforeDelete callback before remove

func (*Building) BeforeSave

func (q *Building) BeforeSave() (err error)

BeforeSave callback before save

func (*Building) BeforeUpdate

func (q *Building) BeforeUpdate() (err error)

BeforeUpdate callback before update

func (*Building) Create

func (q *Building) Create(dbh *gorm.DB) (int64, error)

Create add a row from the store

func (*Building) Delete

func (q *Building) Delete(dbh *gorm.DB) error

Delete remove a row from the store base on id

func (*Building) Get

func (q *Building) Get(dbh *gorm.DB) (*Building, error)

Get query from the db base on id

func (*Building) GetAll

func (q *Building) GetAll(dbh *gorm.DB, page, limit int) (BuildingGetResults, error)

GetAll query all from the db

func (*Building) HashKey

func (q *Building) HashKey(s string) string

HashKey convert to md5 hash

func (Building) TableName

func (Building) TableName() string

TableName table name to be buildings

func (*Building) Update

func (q *Building) Update(dbh *gorm.DB) error

Update modify old data

type BuildingCreator

type BuildingCreator interface {
	Get(dbh *gorm.DB) (*Building, error)
	GetAll(dbh *gorm.DB) ([]Building, error)
	Create(dbh *gorm.DB) (int64, error)
	Update(dbh *gorm.DB) error
	Delete(dbh *gorm.DB) error
}

BuildingCreator list of all building funcs

type BuildingFloor

type BuildingFloor struct {
	ID         int64     `gorm:"primary_key" json:"-"`
	Floor      string    `json:"floor,omitempty"`
	BuildingID int64     `json:"-"`
	CreatedAt  time.Time `json:"-"`
	UpdatedAt  time.Time `json:"-"`
}

BuildingFloor table building_floors

func (BuildingFloor) TableName

func (BuildingFloor) TableName() string

TableName table name to be buildings

type BuildingGetResults

type BuildingGetResults struct {
	Items []Building `json:"items,omitempty"`
	Page  int        `json:"page,omitempty"`
	Limit int        `json:"limit,omitempty"`
	Total int        `json:"total,omitempty"`
}

BuildingGetResults table buildings query list

Jump to

Keyboard shortcuts

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