db

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpDb added in v0.0.6

func DumpDb(db *Db, out io.Writer) error

DumpDb dumps the entire db to a file

Types

type Db

type Db struct {
	// contains filtered or unexported fields
}

Db is used for all db access in the application. We will eventually turn this into an interface to handle multiple Db backends.

func NewDb

func NewDb(dataDir string, init bool) (*Db, error)

NewDb creates a new Db instance for the app

func (*Db) Device

func (db *Db) Device(id string) (ret data.Device, err error)

Device returns data for a particular device

func (*Db) DeviceActivity added in v0.0.6

func (db *Db) DeviceActivity(id string) error

DeviceActivity is used to tell the system there has been activity from this device

func (*Db) DeviceCmds added in v0.0.6

func (db *Db) DeviceCmds() (ret []data.DeviceCmd, err error)

DeviceCmds returns all commands for device

func (*Db) DeviceDelete

func (db *Db) DeviceDelete(id string) error

DeviceDelete deletes a device from the database

func (*Db) DeviceEach added in v0.0.6

func (db *Db) DeviceEach(callback func(device *data.Device) error) error

DeviceEach iterates through each device calling provided function

func (*Db) DeviceGetCmd

func (db *Db) DeviceGetCmd(id string) (data.DeviceCmd, error)

DeviceGetCmd gets a cmd for a device. If the cmd is no null, the command is deleted, and the cmdPending flag cleared in the Device data structure.

func (*Db) DeviceSample

func (db *Db) DeviceSample(id string, sample data.Sample) error

DeviceSample processes a sample for a particular device

func (*Db) DeviceSetCmd

func (db *Db) DeviceSetCmd(cmd data.DeviceCmd) error

DeviceSetCmd sets a cmd for a device, and sets the CmdPending flag in the device structure.

func (*Db) DeviceSetState added in v0.0.6

func (db *Db) DeviceSetState(id string, state data.SysState) error

DeviceSetState is used to set the current system state

func (*Db) DeviceSetVersion

func (db *Db) DeviceSetVersion(id string, ver data.DeviceVersion) error

DeviceSetVersion sets a cmd for a device, and sets the

func (*Db) DeviceUpdateConfig

func (db *Db) DeviceUpdateConfig(id string, config data.DeviceConfig) error

DeviceUpdateConfig updates the config for a device.

func (*Db) DeviceUpdateGroups added in v0.0.6

func (db *Db) DeviceUpdateGroups(id string, groups []uuid.UUID) error

DeviceUpdateGroups updates the groups for a device.

func (*Db) Devices

func (db *Db) Devices() (ret []data.Device, err error)

Devices returns all devices.

func (*Db) DevicesForGroup added in v0.0.6

func (db *Db) DevicesForGroup(tx *bolt.Tx, groupID uuid.UUID) ([]data.Device, error)

DevicesForGroup returns the devices which are property of the given Group.

func (*Db) DevicesForUser added in v0.0.6

func (db *Db) DevicesForUser(userID uuid.UUID) ([]data.Device, error)

DevicesForUser returns all devices for a particular user

func (*Db) Group added in v0.0.6

func (db *Db) Group(id uuid.UUID) (data.Group, error)

Group returns the Group with the given ID.

func (*Db) GroupDelete added in v0.0.6

func (db *Db) GroupDelete(id uuid.UUID) error

GroupDelete deletes a device from the database

func (*Db) GroupInsert added in v0.0.6

func (db *Db) GroupInsert(group data.Group) (string, error)

GroupInsert inserts a new group

func (*Db) GroupUpdate added in v0.0.6

func (db *Db) GroupUpdate(gUpdate data.Group) error

GroupUpdate updates a group

func (*Db) Groups added in v0.0.6

func (db *Db) Groups() ([]data.Group, error)

Groups returns all groups.

func (*Db) UserByEmail added in v0.0.6

func (db *Db) UserByEmail(email string) (data.User, error)

UserByEmail returns the user with the given email, if it exists.

func (*Db) UserByID added in v0.0.6

func (db *Db) UserByID(id string) (data.User, error)

UserByID returns the user with the given ID, if it exists.

func (*Db) UserCheck added in v0.0.6

func (db *Db) UserCheck(email, password string) (*data.User, error)

UserCheck checks user authenticatino

func (*Db) UserDelete added in v0.0.6

func (db *Db) UserDelete(id uuid.UUID) error

UserDelete deletes a user from the database

func (*Db) UserInsert added in v0.0.6

func (db *Db) UserInsert(user data.User) (string, error)

UserInsert inserts a new user

func (*Db) UserIsRoot added in v0.0.6

func (db *Db) UserIsRoot(id uuid.UUID) (bool, error)

UserIsRoot checks if root user

func (*Db) UserUpdate added in v0.0.6

func (db *Db) UserUpdate(user data.User) error

UserUpdate updates a new user

func (*Db) Users added in v0.0.6

func (db *Db) Users() ([]data.User, error)

Users returns all users.

type Influx

type Influx struct {
	// contains filtered or unexported fields
}

Influx represents and influxdb that we can write samples to

func NewInflux

func NewInflux(url, dbName, user, password string) (*Influx, error)

NewInflux creates an influx helper client

func (*Influx) WriteSamples

func (i *Influx) WriteSamples(samples []data.Sample) error

WriteSamples to influxdb

Jump to

Keyboard shortcuts

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