models

package
v0.0.0-...-7b599ff Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Model
	Name           string    `json:"name" db:"NAME"`
	Timestamp      time.Time `json:"timestamp" db:"TIMESTAMP"`
	Camera         string    `json:"camera" db:"CAMERA"`
	Severity       string    `json:"severity" db:"SEVERITY"`
	Message        string    `json:"message" db:"MESSAGE"`
	AcknowledgedAt NullTime  `json:"acknowledged_at,omitempty" db:"ACKNOWLEDGED_AT"`
	ResolvedAt     NullTime  `json:"resolved_at,omitempty" db:"RESOLVED_AT"`
}

func (*Alert) PrepareCreate

func (v *Alert) PrepareCreate() ([]string, error)

PrepareCreate prepares an Alert object for persistence Returns list of fields to save

func (*Alert) PrepareUpdate

func (v *Alert) PrepareUpdate(id string) ([]string, error)

PrepareUpdate prepares an Alert object for update Returns list of fileds to update

type Camera

type Camera struct {
	Model
	Name      string     `json:"name" db:"NAME"`
	Latitude  float64    `json:"latitude" db:"LATITUDE"`
	Longitude float64    `json:"longitude" db:"LONGITUDE"`
	LocalPath NullString `json:"local_path,omitempty" db:"LOCAL_PATH"`
}

func (*Camera) PrepareCreate

func (v *Camera) PrepareCreate() ([]string, error)

PrepareCreate prepares a Video object for persistence Returns list of fields to save

func (*Camera) PrepareUpdate

func (v *Camera) PrepareUpdate(id string) ([]string, error)

PrepareCreate prepares a Video object for update Returns list of fileds to update

type Descriptor

type Descriptor struct {
	TableName string
	FilterSet store.FilterSet
	Create    string
}

Descriptor describes a table

func AlertDescriptor

func AlertDescriptor() Descriptor

VideoDescriptor describes the Video table (returns name and filterset)

func CameraDescriptor

func CameraDescriptor() Descriptor

CameraDescriptor describes the Video table (returns name and filterset)

func PictureDescriptor

func PictureDescriptor() Descriptor

PictureDescriptor describes the Picture table (returns name and filterset)

func UserDescriptor

func UserDescriptor() Descriptor

UserDescriptor describes the User table (returns name and filterset)

func VideoDescriptor

func VideoDescriptor() Descriptor

VideoDescriptor describes the Video table (returns name and filterset)

func (Descriptor) CreateDb

func (d Descriptor) CreateDb(ctx context.Context, db *sqlx.DB) error

type JsonList

type JsonList struct {
	sql.NullString
	Populated bool
}

Particular type of string that contains a json array of tags

func (JsonList) MarshalJSON

func (n JsonList) MarshalJSON() ([]byte, error)

Scan the field as a json array

func (*JsonList) UnmarshalJSON

func (n *JsonList) UnmarshalJSON(data []byte) error

Value turns the array into a database string

type Media

type Media struct {
	Model
	Timestamp time.Time  `json:"timestamp" db:"TIMESTAMP"`
	Camera    string     `json:"camera" db:"CAMERA"`
	Tags      JsonList   `json:"tags,omitempty" db:"TAGS"`
	MediaURL  NullString `json:"media_url,omitempty" db:"MEDIA_URL"`
}

func (*Media) PrepareCreate

func (v *Media) PrepareCreate() ([]string, error)

PrepareCreate prepares a Media object for persistence Returns list of fields to save

func (*Media) PrepareUpdate

func (v *Media) PrepareUpdate(id string) ([]string, error)

PrepareCreate prepares a Media object for update Returns list of fileds to update

type Model

type Model struct {
	ID         string    `json:"id" db:"ID"`
	CreatedAt  time.Time `json:"created_at" db:"CREATED_AT"`
	ModifiedAt time.Time `json:"modified_at" db:"MODIFIED_AT"`
}

Model is the base for all models. Oracle always caps lock...

func (Model) GetID

func (m Model) GetID() string

GetID returns video ID

func (*Model) PrepareCreate

func (m *Model) PrepareCreate() ([]string, error)

Prepare a model to be created into the database Return list of columns to be written

func (*Model) PrepareUpdate

func (m *Model) PrepareUpdate(id string) ([]string, error)

Prepare a model to be updated to the database Return list of columns to be updated

type NullString

type NullString struct {
	sql.NullString
	Populated bool
}

func (NullString) MarshalJSON

func (n NullString) MarshalJSON() ([]byte, error)

Scan the field as a json array

func (*NullString) UnmarshalJSON

func (n *NullString) UnmarshalJSON(data []byte) error

Value turns the array into a database string

type NullTime

type NullTime struct {
	sql.NullTime
	Populated bool
}

func (NullTime) MarshalJSON

func (n NullTime) MarshalJSON() ([]byte, error)

Scan the field as a json array

func (*NullTime) UnmarshalJSON

func (n *NullTime) UnmarshalJSON(data []byte) error

Value turns the array into a database string

type Role

type Role string
const (
	ROLE_UNSET      Role = ""
	ROLE_READ_ONLY  Role = "READ_ONLY"
	ROLE_READ_WRITE Role = "READ_WRITE"
	ROLE_SERVICE    Role = "SERVICE"
	ROLE_ADMIN      Role = "ADMIN"
)

func (*Role) Scan

func (r *Role) Scan(value any) error

Scan implements sql.Scanner

func (Role) Value

func (r Role) Value() (driver.Value, error)

Value implements driver.Valuer

type User

type User struct {
	Model
	Name     string `json:"name" db:"NAME"`
	Role     Role   `json:"role" db:"ROLE"`
	Password string `json:"password" db:"HASH"` // hashed before persisting
}

func (*User) PrepareCreate

func (v *User) PrepareCreate() ([]string, error)

PrepareCreate prepares a Video object for persistence Returns list of fields to save

func (*User) PrepareUpdate

func (v *User) PrepareUpdate(id string) ([]string, error)

PrepareUpdate prepares an User object for update Returns list of fields to update

Jump to

Keyboard shortcuts

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