database

package
v0.0.0-...-721f978 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package database defines method for interacting with PostgreSQL for persistent data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sql.DB
}

DB is a type used by external packages to implement database operations. DB should be initialized via DBConn function.

func DBConn

func DBConn(dbType, host, user, password string) (DB, error)

DBConn returns a new DB, initialized to connect to the database

func (DB) DeleteReadings

func (db DB) DeleteReadings(core string, start, end time.Time) error

DeleteReadings deletes readings within a specified time span from the database

func (DB) GetLatestReadings

func (db DB) GetLatestReadings(userEmail string) ([]models.Reading, error)

GetLatestReadings retrieves the latest readings for a particular user from the database.

func (DB) GetReadings

func (db DB) GetReadings(core string, start, end time.Time) ([]models.Reading, error)

GetReadings gets readings within a specified time span from the database

func (DB) GetSecret

func (db DB) GetSecret(userEmail string) (secret models.Secret, err error)

GetSecret retreives the secret from the database for the specified user.

func (DB) GetUser

func (db DB) GetUser(email string) (models.User, error)

GetUser gets information from the database pertaining to the specified user.

func (DB) StoreReading

func (db DB) StoreReading(reading models.Reading) error

StoreReading stores a new reading in the database

func (DB) StoreSecret

func (db DB) StoreSecret(userEmail string, secret models.Secret) error

StoreSecret updates the specified user's secret in the database

func (DB) StoreUser

func (db DB) StoreUser(user models.User) error

StoreUser inserts the specified user's information in the database.

Jump to

Keyboard shortcuts

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