Documentation ¶
Overview ¶
package persistence contains our storage layer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
DB is a wrapper around sql.DB. This allows us to access all the functionalities of sql.DB as well as accessing the DB object in our internal functions.
type Options ¶
type Options struct { // UseInMemory forces our persistence layer to use an in-memory sqlite database UseInMemory bool // DSN contains the DSN, such as the file name of our sqlite database DSN string }
Options are database options
type StorageObject ¶
type StorageObject interface { InitTables(db *DB) (err error) PrepareReplace(db *DB) (stmt *sql.Stmt, err error) PrepareList(db *DB) (stmt *sql.Stmt, err error) PrepareGet(db *DB) (stmt *sql.Stmt, err error) PrepareUpdate(db *DB, columns []string) (stmt *sql.Stmt, err error) PrepareDelete(db *DB) (stmt *sql.Stmt, err error) ReplaceIntoArgs() []any UpdateArgs([]string) []any Scan(sc Scanner) (StorageObject, error) }
type StorageOperations ¶
type StorageOperations[T StorageObject] interface { Replace(o StorageObject) (err error) List(args ...any) (list []T, err error) Get(key any) (obj T, err error) Update(key any, in T, columns []string) (out T, err error) Delete(key any) (err error) }
func Ops ¶
func Ops[T StorageObject](db *DB) StorageOperations[T]
func Relationship ¶
func Relationship[T StorageObject, S StorageObject](op StorageOperations[S]) StorageOperations[T]
Click to show internal directories.
Click to hide internal directories.