Help us shape the future of Go! Take the 2026 Go Developer Survey

rdb

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: Apache-2.0 Imports: 6 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPrepare = errors.New("error preparing statement")
	ErrOpen    = errors.New("error opening database connection")
	ErrQuery   = errors.New("error querying from table")
	ErrWrite   = errors.New("error writing to table")

	ErrBuildSQLStmt = fmt.Errorf("error building SQL statement: %w", ErrPrepare)
	ErrTypeConv     = fmt.Errorf("error converting between types: %w", ErrPrepare)

	// when trying to scan a null row
	ErrNoRows = errors.New("no rows in result set")
)

Functions

This section is empty.

Types

type Conn

type Conn interface {
	Begin() (Tx, error)
	Exec(sql string, args ...interface{}) (ExecResult, error)
	Query(sql string, args ...interface{}) (RowsResult, error)
	QueryRow(sql string, args ...interface{}) RowResult
	ToHandle() *Handle
}

type CustomTotalQueryFn

type CustomTotalQueryFn = func(conn *Handle, originalSelectBuilder sq.SelectBuilder) (int64, error)

type ExecResult

type ExecResult interface {
	RowsAffected() int64
	IsInsert() bool
	IsUpdate() bool
	IsDelete() bool
	IsSelect() bool
	String() string
}

type Handle

type Handle struct {
	Runner
	TypeConv

	StmtBuilder *StatementBuilder
}

type Migrate

type Migrate interface {
	// Up() looks at the currently active migration version and migrate all the
	// way up.
	Up() error
	MustUp()
	// Down() looks at the currently active migration version and migrate all
	// the way down.
	Down() error
	MustDown()
	// Reset() deletes everything in the database (including migration
	// histories).
	Reset() error
	MustReset()
	// Version() returns the current active migration version and whether the
	// database is at dirty state
	Version() (version uint, dirty bool, err error)
}

type NtobReader

type NtobReader interface {
	// returns reference to a scannable argument of native numeric type
	ScannableArg() interface{}
	// parse the scannable argument reference to big.Int
	Parse() (*big.Int, error)
}

type NtobfReader

type NtobfReader interface {
	// returns reference to a scannable argument of native numeric type
	ScannableArg() interface{}
	// parse the scannable argument reference to big.Float
	Parse() (*big.Float, error)
}

type NtotReader

type NtotReader interface {
	// returns reference to a scannable argument of native time type
	ScannableArg() interface{}
	// parse the scannable argument reference to time.Time
	Parse() (*utctime.UTCTime, error)
}

type RDbPaginationBuilder

type RDbPaginationBuilder struct {
	*pagination_interface.Pagination
	// contains filtered or unexported fields
}

RDbPaginationBuilder builds pagination query based on the pagination data. It supports both SQL and StmtBuilder

func NewRDbPaginationBuilder

func NewRDbPaginationBuilder(pagination *pagination_interface.Pagination, rdbHandle *Handle) *RDbPaginationBuilder

func (*RDbPaginationBuilder) BuildSQL

func (pagination *RDbPaginationBuilder) BuildSQL(sql string, args ...interface{}) *RDbPaginationSQLBuilder

func (*RDbPaginationBuilder) BuildStmt

func (pagination *RDbPaginationBuilder) BuildStmt(stmtBuilder sq.SelectBuilder) *RDbPaginationStmtBuilder

func (*RDbPaginationBuilder) WithCustomTotalQueryFn

func (pagination *RDbPaginationBuilder) WithCustomTotalQueryFn(fn CustomTotalQueryFn) *RDbPaginationBuilder

type RDbPaginationSQLBuilder

type RDbPaginationSQLBuilder struct {
	*pagination_interface.Pagination
	// contains filtered or unexported fields
}

RDbPaginationBuilder is the concrete implementation to builds the pagination for SQL query

func (*RDbPaginationSQLBuilder) Result

func (*RDbPaginationSQLBuilder) ToSQL

func (pagination *RDbPaginationSQLBuilder) ToSQL() (string, []interface{})

type RDbPaginationStmtBuilder

type RDbPaginationStmtBuilder struct {
	*pagination_interface.Pagination
	// contains filtered or unexported fields
}

RDbPaginationBuilder is the concrete implementation to builds the pagination for StmtBuilder

func (*RDbPaginationStmtBuilder) Result

func (*RDbPaginationStmtBuilder) ToStmtBuilder

func (pagination *RDbPaginationStmtBuilder) ToStmtBuilder() sq.SelectBuilder

type RowResult

type RowResult interface {
	Scan(dest ...interface{}) error
}

type RowsResult

type RowsResult interface {
	Close()
	Err() error
	ExecResult() ExecResult
	Next() bool
	// When no row was found it should return ErrNoRows
	Scan(dest ...interface{}) error
}

type Runner

type Runner interface {
	Exec(sql string, args ...interface{}) (ExecResult, error)
	Query(sql string, args ...interface{}) (RowsResult, error)
	QueryRow(sql string, args ...interface{}) RowResult
}

Implementing Conn and Tx interface automatically fulfills Runner

type StatementBuilder added in v1.0.1

type StatementBuilder struct {
	sq.StatementBuilderType
	sq.PlaceholderFormat
}

func NewStatementBuilder added in v1.0.1

func NewStatementBuilder(builder sq.StatementBuilderType, placeholderFormat sq.PlaceholderFormat) *StatementBuilder

type Tx

type Tx interface {
	Exec(sql string, args ...interface{}) (ExecResult, error)
	Query(sql string, args ...interface{}) (RowsResult, error)
	QueryRow(sql string, args ...interface{}) RowResult
	Commit() error
	Rollback() error
	ToHandle() *Handle
}

type TypeConv

type TypeConv interface {
	// convert big.Int to native number pointer. Return nil if big.Int is nil
	Bton(*big.Int) interface{}
	// convert big.Float to native number pointer. Return nil if big.Float is nil
	BFton(*big.Float) interface{}
	Iton(int) interface{}
	// native number reader and parser to big.Int
	NtobReader() NtobReader
	// native number reader and parser to big.Float
	NtobfReader() NtobfReader

	// convert time.Time to native time format pointer. Return nil if time
	// is nil
	Tton(*utctime.UTCTime) interface{}
	// native time reader and parser to time.Time
	NtotReader() NtotReader
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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