database

package
v0.0.0-...-240b47d Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	BeginTx(ctx context.Context) (Transaction, error)
	Close()
	Exec(query string, args ...interface{}) (sql.Result, error)
	InsertOne(ctx context.Context, query string, args ...interface{}) (int64, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

func CreateConnection

func CreateConnection(connStr string) Database

type Error

type Error struct {
	Msg   string
	Query string
	Base  error
}

func (Error) Error

func (e Error) Error() string

type RealDatabase

type RealDatabase struct {
	Wrapped *sql.DB
}

func (RealDatabase) BeginTx

func (db RealDatabase) BeginTx(ctx context.Context) (Transaction, error)

func (RealDatabase) Close

func (db RealDatabase) Close()

func (RealDatabase) Exec

func (db RealDatabase) Exec(query string, args ...interface{}) (sql.Result, error)

func (RealDatabase) InsertOne

func (db RealDatabase) InsertOne(ctx context.Context, query string, args ...interface{}) (int64, error)

func (RealDatabase) PrepareContext

func (db RealDatabase) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)

func (RealDatabase) QueryContext

func (db RealDatabase) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

func (RealDatabase) QueryRow

func (db RealDatabase) QueryRow(query string, args ...interface{}) *sql.Row

func (RealDatabase) QueryRowContext

func (db RealDatabase) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

type RealTransaction

type RealTransaction struct {
	// contains filtered or unexported fields
}

func (RealTransaction) Commit

func (tx RealTransaction) Commit() error

func (RealTransaction) InsertOne

func (tx RealTransaction) InsertOne(ctx context.Context, query string, args ...interface{}) (int64, error)

func (RealTransaction) PrepareContext

func (tx RealTransaction) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)

func (RealTransaction) Rollback

func (tx RealTransaction) Rollback(format string, v ...interface{}) string

type Transaction

type Transaction interface {
	Commit() error
	InsertOne(ctx context.Context, query string, args ...interface{}) (int64, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	Rollback(format string, v ...interface{}) string
}

type UnexpectedRowCountError

type UnexpectedRowCountError struct {
	Op       string
	Expected int64
	Actual   int64
}

func (UnexpectedRowCountError) Error

func (e UnexpectedRowCountError) Error() string

Jump to

Keyboard shortcuts

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