pdb

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoBegin    = errors.New("Can't call Begin on connection")
	ErrNoRollback = errors.New("Can't call Rollback on connection")
	ErrNoCommit   = errors.New("Can't call Commit on connection")
)
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, connString string, sqlgBuilder *sqlg.Builder) error

func NewConnectionFromDb

func NewConnectionFromDb(ident string, db Querier, sqlgBuilder *sqlg.Builder) error

Types

type Connection

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

func GetConnection

func GetConnection(name ...string) *Connection

func (*Connection) Acquire

func (c *Connection) Acquire(ctx context.Context) (*pgxpool.Conn, error)

func (*Connection) Begin

func (c *Connection) Begin(ctx context.Context) (*Connection, error)

Transaction helpers

func (*Connection) Commit

func (c *Connection) Commit(ctx context.Context) error

func (*Connection) GetDB

func (c *Connection) GetDB() Querier

func (*Connection) GlueExec

func (c *Connection) GlueExec(ctx context.Context, q *sqlg.Qg) (pgconn.CommandTag, error)

SQL Glue Helpers

func (*Connection) GlueExecLog

func (c *Connection) GlueExecLog(ctx context.Context, q *sqlg.Qg) (pgconn.CommandTag, error)

func (*Connection) GlueGet

func (c *Connection) GlueGet(ctx context.Context, q *sqlg.Qg, dst interface{}) error

func (*Connection) GlueGetLog

func (c *Connection) GlueGetLog(ctx context.Context, q *sqlg.Qg, dst interface{}) error

func (*Connection) GlueQueryRowScan

func (c *Connection) GlueQueryRowScan(ctx context.Context, q *sqlg.Qg, dst ...interface{}) error

func (*Connection) GlueQueryRowScanLog

func (c *Connection) GlueQueryRowScanLog(ctx context.Context, q *sqlg.Qg, dst ...interface{}) error

func (*Connection) GlueSelect

func (c *Connection) GlueSelect(ctx context.Context, q *sqlg.Qg, dst interface{}) error

func (*Connection) GlueSelectLog

func (c *Connection) GlueSelectLog(ctx context.Context, q *sqlg.Qg, dst interface{}) error

func (*Connection) Rollback

func (c *Connection) Rollback(ctx context.Context) 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) GetFilter

func (l List) GetFilter() sqlg.Qg

func (List) GetParams

func (l List) GetParams() QueryParams

func (List) GetWhere

func (l List) GetWhere() *sqlg.Qg

DEPRECATED

func (*List) QueryOptions

func (l *List) QueryOptions(opt QueryOptions)

func (*List) SetConnection

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

func (*List) SetFilter

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

func (*List) SetParams

func (l *List) SetParams(p QueryParams)

func (*List) SetWhere

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

DEPRECATED

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 Querier

type Querier interface {
	CopyFrom(ctx context.Context, tableName Identifier, columnNames []string, rowSrc CopyFromSource) (int64, error)
	SendBatch(ctx context.Context, b *Batch) BatchResults

	Exec(ctx context.Context, sql string, arguments ...any) (commandTag pgconn.CommandTag, err error)
	Query(ctx context.Context, sql string, args ...any) (Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) Row
}

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)

type QueryParams

type QueryParams map[string]interface{}

type TxBeginer

type TxBeginer interface {
	Begin(context.Context) (pgx.Tx, error)
}

Jump to

Keyboard shortcuts

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