database

package
v0.0.0-...-bcf116b Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package for handling DB operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRecord

func CreateRecord(beacon string, name string, record string, userActions string) (err error, errMsg string)

Create a new record in the database with the given arguments. Should probably validate the arguments.

func Init

func Init()

Initialize the database by creating the sql file if it does not already exist

Types

type DBRow

type DBRow struct {
	Id          int
	Date        string
	Beacon      string
	Name        string
	Record      sql.NullString
	UserActions sql.NullString
}

DBRow is the structure of the sensor table in the database. Each field is exported so that it can be json encoded. Record can be empty (null) so it uses the sql type NullString.

func ReadRecords

func ReadRecords(useSampleDB bool) ([]DBRow, error, string)

Retrieve all data from the database. If isTesting is true, get records from sample database instead of the real one. If error has occurred, return the error along with the descriptive error message

func (DBRow) String

func (item DBRow) String() string

Parse DBItem into string format for logging purpose

Jump to

Keyboard shortcuts

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