pg

package
v0.0.0-...-38cdf9c Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Conn

func Conn() *sqlx.DB

Conn - Gives default connection

func Connect

func Connect(
	gtx context.Context, url *url.URL, timeZone string) (*sqlx.DB, error)

connect - connects to DB based on connection string or URL

func ConnectWithOpts

func ConnectWithOpts(
	gtx context.Context, opts *ConnOpts) (*sqlx.DB, error)

ConnectWithOpts - connect to postgresdb based on given options

func GetFilterValues

func GetFilterValues(
	gtx context.Context,
	dtype string,
	specs []*data.FilterSpec,
	filter *data.Filter) (*data.FilterValues, error)

func InsertQuery

func InsertQuery(table string, fields ...string) string

InsertQuery - creates a basic insert/create query from table name and fields. This query should only be used with named exec i.e with name parameters. The field names are also used to name the parameters

func NamedConn

func NamedConn(name string) *sqlx.DB

NamedConn - gives connection to database associated with given name. If no connection exists with given name nil is returned. If name is empty default connection is returned

func NewGetterDeleter

func NewGetterDeleter() data.GetterDeleter

func PrintDbTime

func PrintDbTime()

func Rollback

func Rollback(op string, tx *sqlx.Tx)

func SetDefaultConn

func SetDefaultConn(db *sqlx.DB)

SetDefaultConn - sets the default postgres connection

func SetNamedConn

func SetNamedConn(name string, db *sqlx.DB)

SetNamedConn - register a postgres connection against name

func Wrap

func Wrap(cmd *cli.Command) *cli.Command

Types

type ConnOpts

type ConnOpts struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	User     string `json:"user"`
	Password string `json:"password"`
	DBName   string `json:"dbName"`
	TimeZone string `json:"timeZone"`
}

ConnOpts - postgres connection options

func (*ConnOpts) String

func (c *ConnOpts) String() string

String - get usable connection string

func (*ConnOpts) Url

func (c *ConnOpts) Url() (*url.URL, error)

Url - get a postgres URL

type Selector

type Selector struct {
	QueryFragment string
	Args          []interface{}
}

func NewSel

func NewSel(qf string, args []interface{}) Selector

func (Selector) IsEmpty

func (sel Selector) IsEmpty() bool

type SelectorGenerator

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

func NewSelectorGenerator

func NewSelectorGenerator() *SelectorGenerator

func (*SelectorGenerator) Reset

func (gen *SelectorGenerator) Reset() *SelectorGenerator

func (*SelectorGenerator) Selector

func (gen *SelectorGenerator) Selector(filter *data.Filter) Selector

func (*SelectorGenerator) SelectorX

func (gen *SelectorGenerator) SelectorX(cmnParam *data.CommonParams) Selector

Jump to

Keyboard shortcuts

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