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
- Variables
- func AddColumnLastUsedTimestamp(c *sqlx.DB) error
- func Close()
- func Connect()
- func CreateTableAppSettings(c *sqlx.DB) error
- func CreateTableCard(c *sqlx.DB) error
- func CreateTableCompanyInfo(c *sqlx.DB) error
- func CreateTableUsers(c *sqlx.DB) error
- func RegisterDeployFunc(f ...deployFunc)
- func SetConfig(c config)
- type Bindvars
Constants ¶
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
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 ¶
var Config = config{ PathToDatabaseFile: "", UseSQLite: false, }
Config is a copy of the config with some defaults set
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 ¶
AddColumnLastUsedTimestamp adds the LastUsedTimestamp column card table if it doesn't already exist
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 ¶
CreateTableAppSettings creates the card table there should only ever be one record in this table
func CreateTableCard ¶
CreateTableCard creates the card table
func CreateTableCompanyInfo ¶
CreateTableCompanyInfo creates the companyInfo table there should only ever be one record in this table
func CreateTableUsers ¶
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.