DataHouse/models/temperature/temperature.go

35 lines
539 B
Go

package temperature
import (
"github.com/astaxie/beego/orm"
"datahouse/models/database"
"time"
)
type tempTable struct {
Id int64
HorodateGMT time.Time `orm:"auto_now;type(datetime)"`
SensorID int64
Value int64
}
func init() {
orm.RegisterModel(new(tempTable))
}
/**
* Add the value into the database.
*/
func AddData(sensor, value int64) {
o := orm.NewOrm()
o.Using(database.Alias)
tmpTable := new(tempTable)
tmpTable.Value = value
tmpTable.SensorID = sensor
o.Insert(tmpTable)
}