state

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BOOL

func BOOL(dbType string, value bool) string

func DATE_SINCE

func DATE_SINCE(dbType string, value int, interval string) string

interval must be minute, hour, second TODO support more

func DEFAULT_TIMESTAMP

func DEFAULT_TIMESTAMP(dbType string) string

func IGNORE

func IGNORE(dbType string) string

func JSON

func JSON(dbType string, value string) string

Important, in JSON entries, must not have surrounding `'` because need to be able to stick in NULL with no `'`

func PRIMARY_KEY

func PRIMARY_KEY(dbType string) string

Types

type DBManager

type DBManager interface {
	/// IsReady will indicate if the SQL connection is ready
	IsReady() bool

	// IsLocked returns if the DB is available but locked
	IsLocked() bool

	// IsInitialized returns if the DB has ever been created
	IsInitialized() bool

	Type() string

	// Unlock will unlock an SQL database with a key/passphrase
	Unlock(string) error

	// RegisterInitScript will register initialization scripts
	// WILL PANIC IF ANY OF THESE SCRIPTS DO NOT RUN
	RegisterInitScript(string)

	// SafeQuery will query safely if the DB is ready
	SafeQuery(query string, args ...interface{}) (Rows, error)
	// SafeExec will query safely if the DB is ready
	SafeExec(query string, args ...interface{}) (Result, error)

	// GetKey gets a value
	GetKey(key []byte) (string, error)

	// SetKey sets a key with a value
	SetKey(key []byte, value []byte) error

	// DelKey deletes a key
	DelKey(key []byte) error

	KVDB() *bolt.DB
}

func NewDB

func NewDB(dbType, connection string, kvdbpath string) (DBManager, error)

type Result

type Result interface {
	// LastInsertId returns the integer generated by the database
	// in response to a command. Typically this will be from an
	// "auto increment" column when inserting a new row. Not all
	// databases support this feature, and the syntax of such
	// statements varies.
	LastInsertId() (int64, error)

	// RowsAffected returns the number of rows affected by an
	// update, insert, or delete. Not every database or database
	// driver may support this.
	RowsAffected() (int64, error)
}

Create a passthrough interface for db.Result to allow for mocking

type Rows

type Rows interface {
	Next() bool
	NextResultSet() bool
	Err() error
	Columns() ([]string, error)
	ColumnTypes() ([]*sql.ColumnType, error)
	Scan(dest ...interface{}) error
	Close() error
}

Create a passthrough interface for db.Rows to allow for mocking

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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