models

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoMigrations

func AutoMigrations(db *Database)

AutoMigrations func automate database schema migrations

func Delete

func Delete(id string, db *Database) (interface{}, error)

Delete sensors from database

func GetAll

func GetAll(db *Database) interface{}

GetAll sensors

func GetByID

func GetByID(id string, db *Database) interface{}

GetByID sensors

Types

type Database

type Database struct {
	*gorm.DB
}

Database struct to connect to gorm

func New

func New(dbUser, dbPass, dbHost, dbPort, dbName string) (*Database, error)

New return new connection pool

type Sensor

type Sensor struct {
	gorm.Model
	// ID        uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Name string `gorm:"type:varchar(20);unique_index" json:"name"`
	Type string `gorm:"type:varchar(40);not null;unique_index" json:"type"`
}

Sensor struct

func (*Sensor) NewSensor

func (s *Sensor) NewSensor(db *Database) (interface{}, error)

NewSensor add new sensor to database

func (*Sensor) UpdateSensor

func (s *Sensor) UpdateSensor(db *Database) (interface{}, error)

UpdateSensor update sensor name

Jump to

Keyboard shortcuts

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