sqliteutils

package
v5.2.0--beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package sqliteutils is used to interact with a sqlite db.

This file holds the SQL code to deploy a new copy of the database. The SQL code should roughly match the fields in the structs used to interact with the database data, ex: card.CustomerDatastore.

Package sqliteutils is used to interact with a sqlite db.

Index

Constants

View Source
const (
	TableUsers       = "users"
	TableCards       = "card"
	TableCompanyInfo = "companyInfo"
	TableAppSettings = "appSettings"
)

these are the names of the tables used to store data these values should match the entity names in datastoreutils.go

View Source
const (
	DefaultCompanyInfoID = 1
	DefaultAppSettingsID = 1
)

these are the default IDs of the rows in the companyInfo and appSettings tables these tables will only ever have one record, so we know what the ID should be

Variables

View Source
var Config = config{
	PathToDatabaseFile: "",
	UseSQLite:          false,
}

Config is a copy of the config with some defaults set

View Source
var Connection *sqlx.DB

Connection is a global variable for using a connection to the db. This is what we use to run queries on the database. This is a "pooled" connection.

Functions

func AddColumnLastUsedTimestamp

func AddColumnLastUsedTimestamp(c *sqlx.DB) error

AddColumnLastUsedTimestamp adds the LastUsedTimestamp column card table if it doesn't already exist

func Close

func Close()

Close closes the connection to the database.

func Connect

func Connect()

Connect establishes and tests a connection to a db if this returns successfully, queries can be run on the db.

func CreateTableAppSettings

func CreateTableAppSettings(c *sqlx.DB) error

CreateTableAppSettings creates the card table there should only ever be one record in this table

func CreateTableCard

func CreateTableCard(c *sqlx.DB) error

CreateTableCard creates the card table

func CreateTableCompanyInfo

func CreateTableCompanyInfo(c *sqlx.DB) error

CreateTableCompanyInfo creates the companyInfo table there should only ever be one record in this table

func CreateTableUsers

func CreateTableUsers(c *sqlx.DB) error

CreateTableUsers creates the users table

func RegisterDeployFunc

func RegisterDeployFunc(f ...deployFunc)

RegisterDeployFunc saves a func that is used to deploy the database to the deployFuncs variable so we can use this func when deploying the database. Using this func makes it so the deployFunc type or the deployFuncs list of funcs isn't accessible outside of this package.

func SetConfig

func SetConfig(c config)

SetConfig saved the configuration options for using sqlite

Types

type Bindvars

type Bindvars []interface{}

Bindvars is used to hold the SQL query parameters parameters are used in WHERE, INSERT, UPDATE, etc.

Jump to

Keyboard shortcuts

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