model

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionSchema = `` /* 135-byte string literal not displayed */

	OxiRecordSchema = `` /* 136-byte string literal not displayed */

)

Variables

View Source
var ErrNotFound = errors.New("Record not found in database")

Functions

This section is empty.

Types

type DB

type DB struct {
	*sqlx.DB
}

func (*DB) FetchAllSessions

func (db *DB) FetchAllSessions() ([]*Session, error)

func (*DB) FetchLatestSession

func (db *DB) FetchLatestSession() (*Session, error)

func (*DB) FetchPreviousSession

func (db *DB) FetchPreviousSession() (*Session, error)

func (*DB) FetchRecords

func (db *DB) FetchRecords(from, to time.Time) ([]*OxiRecord, error)

func (*DB) FetchRecordsBySessionID

func (db *DB) FetchRecordsBySessionID(sessionID int64) ([]*OxiRecord, error)

func (*DB) FetchSessionByStartTime

func (db *DB) FetchSessionByStartTime(start time.Time) (*Session, error)

func (*DB) Initialize

func (db *DB) Initialize() error

func (*DB) SaveRecords

func (db *DB) SaveRecords(records []*OxiRecord) error

func (*DB) SaveSession

func (db *DB) SaveSession(session *Session) error

type Datastore

type Datastore interface {
	Initialize() error
	SaveRecords(records []*OxiRecord) error
	FetchRecords(from, to time.Time) ([]*OxiRecord, error)
	FetchRecordsBySessionID(id int64) ([]*OxiRecord, error)
	SaveSession(session *Session) error
	FetchLatestSession() (*Session, error)
	FetchPreviousSession() (*Session, error)
	FetchSessionByStartTime(start time.Time) (*Session, error)
	FetchAllSessions() ([]*Session, error)
}

func NewDB

func NewDB(driver, dsn string) (Datastore, error)

type OxiRecord

type OxiRecord struct {
	DateTime  time.Time `db:"date_time" json:"date_time"`
	SessionID int64     `db:"session_id" json:"session_id"`
	Pulse     uint8     `db:"pulse" json:"pulse"`
	Spo2      uint8     `db:"spo2" json:"spo2"`
}

func (*OxiRecord) String

func (r *OxiRecord) String() string

type Session

type Session struct {
	ID        int64     `db:"id" json:"id"`
	StartTime time.Time `db:"start_time" json:"start_time"`
	Model     string    `db:"model" json:"model"`
	Seconds   int       `db:"duration_seconds" json:"duration_seconds"`
}

func (*Session) String

func (s *Session) String() string

Jump to

Keyboard shortcuts

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