model

package
v0.0.0-...-586bb61 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2018 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DATETIME = "2006-01-02 15:04:05 -0700 MST"
)

Variables

View Source
var (
	LAST_POST_SUCCESSIVE bool   = true
	SENSOR_ID            string = os.Getenv("SENSOR_ID")
)

Functions

func CreateTable

func CreateTable(db *sql.DB)

func DeleteFromDB

func DeleteFromDB(db *sql.DB, id int) (bool, error)

func InitDB

func InitDB(filepath string) *sql.DB

func Insert

func Insert(db *sql.DB, sds []SerialData)

func PostOrSaveDB

func PostOrSaveDB(bytes_recive []byte, db *sql.DB, c *http.Client, url string)

Types

type SerialData

type SerialData struct {
	Id          int       `json:"id"`
	Humidity    float64   `json:"humidity"`
	Temperature float64   `json:"temperature"`
	CO          float64   `json:"co"`
	CO2         float64   `json:"co2"`
	MP25        float64   `json:"mp25"`
	CreatedAt   time.Time `json:"created_at"`
}

func NewSerialData

func NewSerialData(m []byte) (*SerialData, error)

func Read

func Read(db *sql.DB, limit bool) []SerialData

func ReadAndPost

func ReadAndPost(db *sql.DB, c *http.Client, url string) (SerialData, error)

func (*SerialData) DecodeAndPost

func (sd *SerialData) DecodeAndPost(c *http.Client, url string) (*http.Response, error)

func (*SerialData) Delete

func (sd *SerialData) Delete(db *sql.DB)

Jump to

Keyboard shortcuts

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