summary refs log tree commit diff stats
path: root/svc/sqlite.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-12-19 21:21:56 -0500
committerBen Morrison <ben@gbmor.dev>2019-12-19 21:21:56 -0500
commite53b843a93922f21289b9fc4958f1dfc47a49bdf (patch)
treea98cc9358ccf773a7615b42802bb825d7be0bc0d /svc/sqlite.go
parent7db28dd705dd5463b5e2e9cf6f5fc87db25533ad (diff)
downloadgetwtxt-e53b843a93922f21289b9fc4958f1dfc47a49bdf.tar.gz
some functions were missing comments. added those in where needed.
Diffstat (limited to 'svc/sqlite.go')
-rw-r--r--svc/sqlite.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/svc/sqlite.go b/svc/sqlite.go
index 572651f..58a804d 100644
--- a/svc/sqlite.go
+++ b/svc/sqlite.go
@@ -28,12 +28,16 @@ import (
 	_ "github.com/mattn/go-sqlite3" // for the sqlite3 driver
 )
 
+// Wrapper containing a SQLite database connection,
+// along with two prepared statements for pushing
+// and pulling via said connection.
 type dbSqlite struct {
 	db       *sql.DB
 	pullStmt *sql.Stmt
 	pushStmt *sql.Stmt
 }
 
+// Initializes a SQLite database.
 func initSqlite() *dbSqlite {
 	confObj.Mu.RLock()
 	dbpath := confObj.DBPath
@@ -60,6 +64,7 @@ func initSqlite() *dbSqlite {
 	}
 }
 
+// Commits data from memory to a SQLite database intermittently.
 func (lite *dbSqlite) push() error {
 	if err := lite.db.Ping(); err != nil {
 		lite = initSqlite()
@@ -104,6 +109,7 @@ func (lite *dbSqlite) push() error {
 	return nil
 }
 
+// Retrieves stored data from a SQLite database on startup.
 func (lite *dbSqlite) pull() {
 	errLog("Error pinging sqlite DB: ", lite.db.Ping())
 	rows, err := lite.pullStmt.Query()