db

package
v0.0.0-...-8050983 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTypeAssertionArrayByte          = errors.New("Type assertion .([]byte) failed.")
	ErrTypeAssertionMapStringInterface = errors.New("Type assertion .(map[string]interface{}) failed.")
)
View Source
var ErrDbIsNil = errors.New("Database identifier is nil")
View Source
var ErrInputIsNotMap = errors.New("Input is not map type")
View Source
var (
	ErrNoLimitDefined = errors.New("No limit defined")
)

Functions

func NewConnection

func NewConnection(ident, dbtype, connString string, sqlgBuilder *sqlg.Builder) (err error)

func NewConnectionFromDb

func NewConnectionFromDb(ident string, db *sqlx.DB, sqlgBuilder *sqlg.Builder) (err error)

Types

type Connection

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

func GetConnection

func GetConnection(name ...string) *Connection

func (*Connection) Begin

func (c *Connection) Begin() (*Connection, error)

Transaction helpers

func (*Connection) Commit

func (c *Connection) Commit() error

func (*Connection) GetDB

func (c *Connection) GetDB() *sqlx.DB

func (*Connection) GetTx

func (c *Connection) GetTx() *sqlx.Tx

func (*Connection) GlueExec

func (c *Connection) GlueExec(q *sqlg.Qg) error

SQL Glue Helpers

func (*Connection) GlueExecLog

func (c *Connection) GlueExecLog(q *sqlg.Qg) error

func (*Connection) GlueGet

func (c *Connection) GlueGet(q *sqlg.Qg, dest interface{}) error

func (*Connection) GlueGetLog

func (c *Connection) GlueGetLog(q *sqlg.Qg, dest interface{}) error

func (*Connection) GlueQueryRowScan

func (c *Connection) GlueQueryRowScan(q *sqlg.Qg, dest ...interface{}) error

func (*Connection) GlueQueryRowScanLog

func (c *Connection) GlueQueryRowScanLog(q *sqlg.Qg, dest ...interface{}) error

func (*Connection) GlueSelect

func (c *Connection) GlueSelect(q *sqlg.Qg, dest interface{}) error

func (*Connection) GlueSelectLog

func (c *Connection) GlueSelectLog(q *sqlg.Qg, dest interface{}) error

func (*Connection) Rollback

func (c *Connection) Rollback() error

func (*Connection) WithContext

func (c *Connection) WithContext(ctx context.Context) *Connection

type DbQuerier

type DbQuerier interface {
	Get(dest interface{}, query string, args ...interface{}) error
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	MustExec(query string, args ...interface{}) sql.Result
	MustExecContext(ctx context.Context, query string, args ...interface{}) sql.Result
	NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
	Preparex(query string) (*sqlx.Stmt, error)
	QueryRowx(query string, args ...interface{}) *sqlx.Row
	QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
	Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
	QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
	Rebind(query string) string
	Select(dest interface{}, query string, args ...interface{}) error
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
}

type JsonB

type JsonB map[string]interface{}

func (*JsonB) Scan

func (b *JsonB) Scan(src interface{}) error

func (JsonB) Value

func (b JsonB) Value() (driver.Value, error)

type List

type List struct {
	Total  int `json:"total"`
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
	// contains filtered or unexported fields
}

func NewList

func NewList(conn *Connection) *List

func (List) ApplyQueryOptions

func (l List) ApplyQueryOptions(q *sqlg.Qg)

func (List) Conn

func (l List) Conn() *Connection

func (List) GetWhere

func (l List) GetWhere() sqlg.Qg

func (*List) QueryOptions

func (l *List) QueryOptions(opt QueryOptions)

func (*List) SetConnection

func (l *List) SetConnection(conn *Connection)

func (*List) SetWhere

func (l *List) SetWhere(qg sqlg.Qg)

type Model

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

func NewModel

func NewModel(conn *Connection) *Model

func (*Model) Conn

func (m *Model) Conn() *Connection

func (*Model) SetConnection

func (m *Model) SetConnection(conn *Connection)

type NullBool

type NullBool struct {
	sql.NullBool
}

func (NullBool) CompareHash

func (v NullBool) CompareHash() []byte

func (NullBool) MarshalJSON

func (nb NullBool) MarshalJSON() ([]byte, error)

func (*NullBool) UnmarshalJSON

func (nb *NullBool) UnmarshalJSON(b []byte) error

type NullFloat64

type NullFloat64 struct {
	sql.NullFloat64
}

func (NullFloat64) CompareHash

func (v NullFloat64) CompareHash() []byte

func (NullFloat64) MarshalJSON

func (nf NullFloat64) MarshalJSON() ([]byte, error)

func (*NullFloat64) UnmarshalJSON

func (nf *NullFloat64) UnmarshalJSON(b []byte) error

type NullInt64

type NullInt64 struct {
	sql.NullInt64
}

func (NullInt64) CompareHash

func (v NullInt64) CompareHash() []byte

func (NullInt64) MarshalJSON

func (ni NullInt64) MarshalJSON() ([]byte, error)

func (*NullInt64) UnmarshalJSON

func (ni *NullInt64) UnmarshalJSON(b []byte) error

type NullString

type NullString struct {
	sql.NullString
}

func (NullString) CompareHash

func (v NullString) CompareHash() []byte

func (NullString) MarshalJSON

func (ns NullString) MarshalJSON() ([]byte, error)

func (*NullString) UnmarshalJSON

func (ns *NullString) UnmarshalJSON(b []byte) error

type NullTime

type NullTime struct {
	pq.NullTime
}

func (NullTime) CompareHash

func (v NullTime) CompareHash() []byte

func (NullTime) MarshalJSON

func (nt NullTime) MarshalJSON() ([]byte, error)

func (*NullTime) UnmarshalJSON

func (nt *NullTime) UnmarshalJSON(b []byte) error

type QueryFilter

type QueryFilter map[string]interface{}

func (QueryFilter) GetFromMap

func (qf QueryFilter) GetFromMap(data interface{}, Allowed []string) error

func (QueryFilter) GetFromURLQuery

func (qf QueryFilter) GetFromURLQuery(uq url.Values, Allowed []string) error

type QueryOptions

type QueryOptions struct {
	Limit       int
	Offset      int
	Page        int
	Sort        []string
	SortAllow   []string
	SortDefault string
}

func (*QueryOptions) ApplyToQuery

func (opt *QueryOptions) ApplyToQuery(sb *sqlg.Qg) error

func (*QueryOptions) GetFromMap

func (qOpts *QueryOptions) GetFromMap(m map[string]string)

func (*QueryOptions) GetFromURLQuery

func (qOpts *QueryOptions) GetFromURLQuery(m url.Values)

Jump to

Keyboard shortcuts

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