db

package
v0.0.0-...-570e589 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CASCADE = "CASCADE"
View Source
const MYSQL_NULL = "null"
View Source
const NOACTION = "NO ACTION"
View Source
const RESTRICT = "RESTRICT"
View Source
const RelatedTaskErrorCode = "Error 1451"
View Source
const SETNULL = "SET NULL"
View Source
const UniqueFieldErrorCode = "Error 1062"

Variables

View Source
var DatabaseTables = []interface{}{
	&domain.Contact{}, &domain.Country{}, &domain.Tag{}, &domain.Task{}, &domain.SpeedTestNetServer{},
	&domain.UserTags{}, &domain.User{}, &domain.Version{}, &domain.TaskLogSpeedTest{},
	&domain.TaskLogPingTest{}, &domain.TaskLogError{}, &domain.TaskLogRestart{}, &domain.TaskLogNetworkDowntime{},
	&domain.ReportingSnapshot{}, &domain.NamedServer{}, &domain.NodeTags{}, &domain.Node{}, &domain.ReportingEvent{}}
View Source
var Db *gorm.DB

Functions

func AreTagsValid

func AreTagsValid(tags []domain.Tag) bool

AreTagsValid returns a bool based on this ...

  • if the input is empty, then true
  • if there is an error getting the tags from the database, then false
  • if any of the tags do not have a UID that matches one that's in the Db, then false
  • if all of the tags have a UID that matches one that's in the Db, then true

func AutoMigrateTables

func AutoMigrateTables() error

func CreateForeignKeys

func CreateForeignKeys() error

func DeleteItem

func DeleteItem(itemObj interface{}, id uint) error

func DeleteOrphanedItems

func DeleteOrphanedItems(itemObj interface{}, relationID string)

itemObj needs to be a pointer relationID should be something like "node_id"

func DropTables

func DropTables() error

func FindOne

func FindOne(itemObj interface{}) error

func GetAuthorizationStatus

func GetAuthorizationStatus(req events.APIGatewayProxyRequest, permissionType string, objectTags []domain.Tag) (int, string)

GetAuthorizationStatus returns 0, nil for users that are authorized to use the object

func GetCountryByCode

func GetCountryByCode(countryCode string) (domain.Country, error)

func GetDb

func GetDb() (*gorm.DB, error)

func GetItem

func GetItem(itemObj interface{}, id uint) error

func GetLatestVersion

func GetLatestVersion() (domain.Version, error)

GetLatestVersion iterates through version in Db to return only the latest version

func GetNodeByMacAddr

func GetNodeByMacAddr(macAddr string) (domain.Node, error)

func GetReportingEvents

func GetReportingEvents(nodeID uint) ([]domain.ReportingEvent, error)

func GetReportingEventsForRange

func GetReportingEventsForRange(nodeId uint, rangeStart, rangeEnd int64) ([]domain.ReportingEvent, error)

func GetSnapshotsForRange

func GetSnapshotsForRange(interval string, nodeId uint, rangeStart, rangeEnd int64) ([]domain.ReportingSnapshot, error)

func GetSpeedTestNetServerByServerID

func GetSpeedTestNetServerByServerID(serverID string) (domain.SpeedTestNetServer, error)

func GetTaskLogForRange

func GetTaskLogForRange(itemObj interface{}, nodeId uint, rangeStart, rangeEnd int64) error

func GetUserFromRequest

func GetUserFromRequest(req events.APIGatewayProxyRequest) (domain.User, error)

func ListItems

func ListItems(itemObj interface{}, order string) error

func ListMIANodes

func ListMIANodes(daysMissing int) ([]domain.Node, error)

func ListNamedServersByType

func ListNamedServersByType(serverType string) ([]domain.NamedServer, error)

func PutItem

func PutItem(itemObj interface{}) error

func PutItemWithAssociations

func PutItemWithAssociations(itemObj interface{}, replacements []domain.AssociationReplacements) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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