stored

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package stored provides interfacing methods for updating/retrieving data from the local sqlite3 database

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBEvaluation

type DBEvaluation evaluate.Evaluation

DBEvaluation is an evaluation that can be stored in a SQL db, it is exactly the same as the evaluation but just with a Scan method implementation for marshalling from JSON

func (*DBEvaluation) Scan

func (d *DBEvaluation) Scan(src interface{}) error

Scan is used when reading the DBEvaluation field in from the SQL db, marshalling from a JSON string

type Evaluation

type Evaluation struct {
	ID         int          `db:"id"`
	Created    time.Time    `db:"created"`
	Evaluation DBEvaluation `db:"val"`
}

Evaluation is an evaluation stored in the database, with an ID and a timestamp

type LocalStore

type LocalStore struct {
	DB *sql.DB
}

LocalStore is the implementation of a Store for updating/retrieving evaluations from a SQL db

func (*LocalStore) AddEvaluation added in v0.2.0

func (s *LocalStore) AddEvaluation(model string, evaluation *evaluate.Evaluation) error

AddEvaluation inserts a new evaluation associated with a model

func (*LocalStore) GetEvaluation added in v0.2.0

func (s *LocalStore) GetEvaluation(model string) ([]*Evaluation, error)

GetEvaluation returns all evaluations associated with a model

func (*LocalStore) GetModel

func (s *LocalStore) GetModel(model string) (*Model, error)

GetModel gets the model with the name provided

func (*LocalStore) RemoveEvaluation added in v0.2.0

func (s *LocalStore) RemoveEvaluation(id int) error

RemoveEvaluation deletes an evaluation by the ID provided

func (*LocalStore) UpdateModel

func (s *LocalStore) UpdateModel(model string, intervalsPassed int) error

UpdateModel updates the model in the DB with the name provided, setting the intervals_passed value

type Model

type Model struct {
	ID              int    `db:"id"`
	Name            string `db:"model_name"`
	IntervalsPassed int    `db:"intervals_passed"`
}

Model is a model stored in the database, with an ID and the number of intervals since it was last used

type Storer added in v0.2.0

type Storer interface {
	GetEvaluation(model string) ([]*Evaluation, error)
	AddEvaluation(model string, evaluation *evaluate.Evaluation) error
	RemoveEvaluation(id int) error
	GetModel(model string) (*Model, error)
	UpdateModel(model string, intervalsPassed int) error
}

Storer allows updating/retrieving evaluations from a data source

Jump to

Keyboard shortcuts

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