Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn interface { Exec(query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row }
Conn is used as a common interface for the stores so they don't need to worry about whether or not there's a transaction.
type DB ¶
type DB struct { Users *userStore Entries *entryStore RefreshTokens *refreshTokenStore // contains filtered or unexported fields }
DB wraps a SQL database with specific functionality
type DBWithTx ¶
type DBWithTx struct { *DB // contains filtered or unexported fields }
DBWithTx wraps a DB with a sql Tx.
type Option ¶
type Option func(*DB)
Option is an option to be applied to the DB.
func AutoCreateDB ¶
func AutoCreateDB() Option
AutoCreateDB returns an option that will configure the DB to automatically create the database in the provided instance if it doesn't exist already.
func DropDBOnClose ¶
func DropDBOnClose() Option
DropDBOnClose returns an option that will configure the DB to drop the underlying database when the DB is closed. This is useful if the database is only needed temporarily e.g. for testing.
func DropExistingDB ¶
func DropExistingDB() Option
DropExistingDB returns an option that will configure the DB to drop the database if it currently exists. This would be useful if the DB needs dropped before using the AutoCreateDB Option.
func WithMigrations ¶
WithMigrations returns an option that will configure the DB to perform automatic migrations. No subdirectories will be searched, and only files with a `.sql` extension will be run. If the directory string provided is empty, no migrations will be run.