Documentation ¶
Index ¶
- func NewDatabaseConnection() *mgo.Database
- type Database
- func (database *Database) DeleteAlarm(alarmID bson.ObjectId) error
- func (database *Database) DeleteNearestAlarm(deviceID bson.ObjectId) error
- func (database *Database) GetAlarm(alarmID bson.ObjectId) (*model.Alarm, error)
- func (database *Database) GetAlarmsByDevice(deviceID bson.ObjectId) ([]*model.Alarm, error)
- func (database *Database) GetDevice(deviceID bson.ObjectId) (*model.Device, error)
- func (database *Database) GetDevices() ([]*model.Device, error)
- func (database *Database) GetNearestAlarm(deviceID bson.ObjectId, date time.Time) (*model.Alarm, error)
- func (database *Database) GetStatisticsDeviceFromToType(deviceID bson.ObjectId, dateFrom time.Time, dateTo time.Time, dataType string) ([]*model.Statistic, error)
- func (database *Database) GetStatisticsTypes(deviceID bson.ObjectId) ([]string, error)
- func (database *Database) InsertAlarm(alarm *model.Alarm) (*bson.ObjectId, error)
- func (database *Database) InsertDevice(device *model.Device) (*bson.ObjectId, error)
- func (database *Database) InsertStatistic(statistic *model.Statistic) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDatabaseConnection ¶
func NewDatabaseConnection() *mgo.Database
NewDatabaseConnection returns new connection to database
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database struct, keeps reference to running database
func NewDatabase ¶
func NewDatabase(connection *mgo.Database) *Database
NewDatabase creates global Database object from database connection
func (*Database) DeleteAlarm ¶
DeleteAlarm by alarmId
func (*Database) DeleteNearestAlarm ¶
DeleteNearestAlarm by deviceID
func (*Database) GetAlarmsByDevice ¶
GetAlarmsByDevice returns array of alarms
func (*Database) GetDevices ¶
GetDevices get all devices from db
func (*Database) GetNearestAlarm ¶
func (database *Database) GetNearestAlarm(deviceID bson.ObjectId, date time.Time) (*model.Alarm, error)
GetNearestAlarm get first alarm to ring
func (*Database) GetStatisticsDeviceFromToType ¶
func (database *Database) GetStatisticsDeviceFromToType(deviceID bson.ObjectId, dateFrom time.Time, dateTo time.Time, dataType string) ([]*model.Statistic, error)
GetStatisticsDeviceFromToType by deviceId, dataFrom, dateTo and dataType
func (*Database) GetStatisticsTypes ¶
GetStatisticsTypes by deviceID
func (*Database) InsertAlarm ¶
InsertAlarm into database
func (*Database) InsertDevice ¶
InsertDevice into database
Click to show internal directories.
Click to hide internal directories.