database

package
v0.0.0-...-a1584db Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2017 License: MIT Imports: 5 Imported by: 0

README

Install MongoDB 3.2

use iot - creates project's database

service mongod start - starts mongoDB

You don't need to create collections, if they won't exists before requests, mongoDB will create them.

Documentation

Index

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

func (database *Database) DeleteAlarm(alarmID bson.ObjectId) error

DeleteAlarm by alarmId

func (*Database) DeleteNearestAlarm

func (database *Database) DeleteNearestAlarm(deviceID bson.ObjectId) error

DeleteNearestAlarm by deviceID

func (*Database) GetAlarm

func (database *Database) GetAlarm(alarmID bson.ObjectId) (*model.Alarm, error)

GetAlarm by alarmID

func (*Database) GetAlarmsByDevice

func (database *Database) GetAlarmsByDevice(deviceID bson.ObjectId) ([]*model.Alarm, error)

GetAlarmsByDevice returns array of alarms

func (*Database) GetDevice

func (database *Database) GetDevice(deviceID bson.ObjectId) (*model.Device, error)

GetDevice by deviceID

func (*Database) GetDevices

func (database *Database) GetDevices() ([]*model.Device, error)

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

func (database *Database) GetStatisticsTypes(deviceID bson.ObjectId) ([]string, error)

GetStatisticsTypes by deviceID

func (*Database) InsertAlarm

func (database *Database) InsertAlarm(alarm *model.Alarm) (*bson.ObjectId, error)

InsertAlarm into database

func (*Database) InsertDevice

func (database *Database) InsertDevice(device *model.Device) (*bson.ObjectId, error)

InsertDevice into database

func (*Database) InsertStatistic

func (database *Database) InsertStatistic(statistic *model.Statistic) error

InsertStatistic into database

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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