database

package
v0.0.0-...-68442fa Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package database provides our database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(l *zap.SugaredLogger)

SetLogger to set log in db instance.

Types

type Sqlite

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

Sqlite struct to represent a class.

func NewSqlite

func NewSqlite(dt devicetypes.DeviceTypes) *Sqlite

NewSqlite method to instantiate class/struct.

func (*Sqlite) AddAction

func (sl *Sqlite) AddAction(a models.Action) (int, error)

AddAction to db.

func (*Sqlite) AddDevice

func (sl *Sqlite) AddDevice(d models.Device) (insertID int)

AddDevice to add a new device.

func (*Sqlite) AddGroup

func (sl *Sqlite) AddGroup(g models.Group) (int, error)

AddGroup to add a group.

func (*Sqlite) AddScene

func (sl *Sqlite) AddScene(s models.Scene) (int, error)

AddScene to db.

func (*Sqlite) AddShow

func (sl *Sqlite) AddShow(s models.Show) (int, error)

AddShow to db.

func (*Sqlite) AddShowCycle

func (sl *Sqlite) AddShowCycle(c models.Cycle) (int, error)

AddShowCycle to db.

func (*Sqlite) DeleteAction

func (sl *Sqlite) DeleteAction(actionID int) error

DeleteAction function.

func (*Sqlite) DeleteDevice

func (sl *Sqlite) DeleteDevice(deviceID int)

DeleteDevice function.

func (*Sqlite) DeleteGroup

func (sl *Sqlite) DeleteGroup(groupID int) error

DeleteGroup function.

func (*Sqlite) DeleteScene

func (sl *Sqlite) DeleteScene(sceneID int) error

DeleteScene to delete a Scene.

func (*Sqlite) DeleteShow

func (sl *Sqlite) DeleteShow(showID int) error

DeleteShow function.

func (*Sqlite) DeleteShowCycle

func (sl *Sqlite) DeleteShowCycle(cycleID int) error

DeleteShowCycle function.

func (*Sqlite) Disconnect

func (sl *Sqlite) Disconnect()

Disconnect database connection.

func (*Sqlite) GetAction

func (sl *Sqlite) GetAction(actionID int) (models.Action, error)

GetAction to return a single Action struct.

func (*Sqlite) GetActionOrderNext

func (sl *Sqlite) GetActionOrderNext(groupID int) (int, error)

GetActionOrderNext to get the next order value.

func (*Sqlite) GetActions

func (sl *Sqlite) GetActions(groupID int) ([]models.Action, error)

GetActions to return a slice of Action structs.

func (*Sqlite) GetDevice

func (sl *Sqlite) GetDevice(deviceID int) models.Device

GetDevice to return a single Device struct.

func (*Sqlite) GetDeviceType

func (sl *Sqlite) GetDeviceType(deviceID int) models.DeviceType

GetDeviceType to return a single DeviceType struct.

func (*Sqlite) GetDeviceTypes

func (sl *Sqlite) GetDeviceTypes() []models.DeviceType

GetDeviceTypes to return a slice of DeviceType structs.

func (*Sqlite) GetDevices

func (sl *Sqlite) GetDevices() []models.Device

GetDevices to return a slice of Device structs.

func (*Sqlite) GetDevicesWithActionSelected

func (sl *Sqlite) GetDevicesWithActionSelected(actionID int) []models.Device

GetDevicesWithActionSelected to return a slice of Device structs with select flags set.

func (*Sqlite) GetDevicesWithSceneSelected

func (sl *Sqlite) GetDevicesWithSceneSelected(sceneID int) ([]models.Device, error)

GetDevicesWithSceneSelected to return a slice of Device structs with select flags set.

func (*Sqlite) GetGroup

func (sl *Sqlite) GetGroup(groupID int) (models.Group, error)

GetGroup to return a single Group struct.

func (*Sqlite) GetGroupOrderNext

func (sl *Sqlite) GetGroupOrderNext(sceneID int) (int, error)

GetGroupOrderNext to get the next order value.

func (*Sqlite) GetGroups

func (sl *Sqlite) GetGroups(sceneID int) ([]models.Group, error)

GetGroups to return a slice of Group structs.

func (*Sqlite) GetScene

func (sl *Sqlite) GetScene(sceneID int) (models.Scene, error)

GetScene to return a single Scene struct.

func (*Sqlite) GetScenes

func (sl *Sqlite) GetScenes() ([]models.Scene, error)

GetScenes to return a slice of Scene structs.

func (*Sqlite) GetShow

func (sl *Sqlite) GetShow(showID int) (models.Show, error)

GetShow to return a single Show struct.

func (*Sqlite) GetShowByTopic

func (sl *Sqlite) GetShowByTopic(topic string) (models.Show, error)

GetShowByTopic to return a single Show struct.

func (*Sqlite) GetShowCycle

func (sl *Sqlite) GetShowCycle(cycleID int) (models.Cycle, error)

GetShowCycle to return a single Show struct.

func (*Sqlite) GetShowCycles

func (sl *Sqlite) GetShowCycles(showID int) ([]models.Cycle, error)

GetShowCycles to return a slice of Cycle structs.

func (*Sqlite) GetShows

func (sl *Sqlite) GetShows() ([]models.Show, error)

GetShows to return a slice of Show structs.

func (*Sqlite) InitializeClient

func (sl *Sqlite) InitializeClient()

InitializeClient is a replacement for init() because we need to set log variable first.

func (*Sqlite) ReturnDevicesWithActionSelected

func (sl *Sqlite) ReturnDevicesWithActionSelected(action models.Action, devices []models.Device) []models.Device

ReturnDevicesWithActionSelected to return a slice of Device structs with select flags set.

func (*Sqlite) SetAction

func (sl *Sqlite) SetAction(a models.Action) error

SetAction to update a Action.

func (*Sqlite) SetDevice

func (sl *Sqlite) SetDevice(d models.Device)

SetDevice to update a device.

func (*Sqlite) SetDeviceTypes

func (sl *Sqlite) SetDeviceTypes(t []models.DeviceType)

SetDeviceTypes to set deviceTypes in db instance.

func (*Sqlite) SetGroup

func (sl *Sqlite) SetGroup(g models.Group) error

SetGroup to update a Group.

func (*Sqlite) SetScene

func (sl *Sqlite) SetScene(s models.Scene) error

SetScene to update a scene.

func (*Sqlite) SetShow

func (sl *Sqlite) SetShow(s models.Show) error

SetShow to update a Show.

func (*Sqlite) SetShowCycle

func (sl *Sqlite) SetShowCycle(c models.Cycle) error

SetShowCycle to update a Cycle.

func (*Sqlite) SortAction

func (sl *Sqlite) SortAction(groupID int, actionID int, sortID int) error

SortAction function.

func (*Sqlite) SortGroup

func (sl *Sqlite) SortGroup(sceneID int, groupID int, sortID int) error

SortGroup to update the sort order of groups.

Jump to

Keyboard shortcuts

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