Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnectorFunc ¶
ConnectorFunc is used to inject a database connection method into NewDatabaseConnection
func NewPostgreSQLConnector ¶
func NewPostgreSQLConnector(log zerolog.Logger) ConnectorFunc
NewPostgreSQLConnector opens a connection to a postgresql database
func NewSQLiteConnector ¶
func NewSQLiteConnector(log zerolog.Logger) ConnectorFunc
NewSQLiteConnector opens a connection to a local sqlite database
type Datastore ¶
type Datastore interface { AddTemperatureMeasurement(device *string, latitude, longitude, temp float64, water bool, when string) (*models.TemperatureV2, error) GetTemperatures(deviceId string, from, to time.Time, geoSpatial string, lat0, lon0, lat1, lon1 float64, resultOffset, resultLimit uint64) ([]models.TemperatureV2, error) }
Datastore is an interface that is used to inject the database into different handlers to improve testability
func GetFromContext ¶
GetFromContext extracts the database wrapper, if any, from the provided context
func NewDatabaseConnection ¶
func NewDatabaseConnection(connect ConnectorFunc) (Datastore, error)
NewDatabaseConnection initializes a new connection to the database and wraps it in a Datastore
Click to show internal directories.
Click to hide internal directories.