db

package
v0.0.0-...-ab68a60 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

MIT License -----------

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	H *gorm.DB
}

func (*DB) AddEvent

func (db *DB) AddEvent(rec *Event, event_data interface{}) (err error)

func (*DB) AddSensorData

func (db *DB) AddSensorData(rec *Sensor) (err error)

func (*DB) AddVideoEvent

func (db *DB) AddVideoEvent(eventId string, videoUri string, thumbnailUri string) (err error)

func (*DB) Close

func (db *DB) Close()

func (*DB) GetEvent

func (db *DB) GetEvent(uuid string) (event Event, err error)

func (*DB) GetEvents

func (db *DB) GetEvents(limit int) (events []Event, count int64, err error)

func (*DB) GetSensors

func (db *DB) GetSensors(limit int) (sensors []Sensor, err error)

func (*DB) GetSensorsForEvent

func (db *DB) GetSensorsForEvent(uuid string) (sensors []Sensor, err error)

func (*DB) GetVideoEventNotUploaded

func (db *DB) GetVideoEventNotUploaded() (videoEvent VideoEvent, err error)

func (*DB) GetVideoEvents

func (db *DB) GetVideoEvents(limit int, page int) (events []VideoEvent, count int64, err error)

func (*DB) GetVideosForEvent

func (db *DB) GetVideosForEvent(uuid string) (videoEvents []VideoEvent, err error)

func (*DB) Open

func (db *DB) Open(driver string, uri string) (err error)

func (*DB) Save

func (db *DB) Save(v interface{})

func (*DB) SetVideoEventWebUri

func (db *DB) SetVideoEventWebUri(eventId string, webUri string, transcodeFailed bool)

func (*DB) StartEvent

func (db *DB) StartEvent(uuid string, ts time.Time, eventType string, eventSource string, sensor string)

func (*DB) StopEvent

func (db *DB) StopEvent(
	uuid string,
	ts time.Time,
	duration int64)

type Event

type Event struct {
	Id        string    `gorm:"type:varchar(40); PRIMARY_KEY"`
	CreatedAt time.Time `gorm:"type:datetime;Column:created_at;index;,sort:desc"`
	StartedAt time.Time `gorm:"type:datetime;Column:started_at"`
	EndedAt   time.Time `gorm:"type:datetime;Column:ended_at"`
	Duration  int64     `gorm:"type:decimal"`
	Type      string    `gorm:"type:varchar(32)"`
	Source    string    `gorm:"type:varchar(32)"`
	Sensor    string    `gorm:"type:varchar(32)"`
}

type Sensor

type Sensor struct {
	EventId   string    `gorm:"column:event_id;null;index;default:NULL;" json:"event_id"`
	CreatedAt time.Time `gorm:"type:datetime;Column:created_at;index;,sort:desc"`
	Data      []byte    `gorm:"type:blob"`
}

type VideoEvent

type VideoEvent struct {
	EventId         string    `gorm:"column:event_id; PRIMARY_KEY" json:"event_id"`
	CreatedAt       time.Time `gorm:"type:datetime;Column:created_at;index;,sort:desc"`
	Uri             string    `gorm:"type:varchar(512)"`
	WebUri          string    `gorm:"type:varchar(512);default:NULL"`
	Thumbnail       string    `gorm:"type:varchar(256)"`
	IsUploaded      bool      `gorm:"default:false;index:is_uploaded_or_pending_idx"`
	IsPending       bool      `gorm:"default:false;index:is_uploaded_or_pending_idx"`
	IsInprogress    bool      `gorm:"default:false"`
	TranscodeFailed bool      `gorm:"default:false"`
}

Jump to

Keyboard shortcuts

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