Documentation ¶
Index ¶
- Constants
- Variables
- func GetArrayByteFromByte(ci *pgtype.ConnInfo, src []byte, name string) (dto sql.RawBytes)
- func GetArrayFloat32FromByte(ci *pgtype.ConnInfo, src []byte, name string) []float32
- func GetArrayFloat64FromByte(ci *pgtype.ConnInfo, src []byte, name string) []float64
- func GetArrayInt16FromByte(ci *pgtype.ConnInfo, src []byte, name string) []int16
- func GetArrayInt32FromByte(ci *pgtype.ConnInfo, src []byte, name string) []int32
- func GetArrayInt64FromByte(ci *pgtype.ConnInfo, src []byte, name string) []int64
- func GetArrayRefTimeFromByte(ci *pgtype.ConnInfo, src []byte, name string) []*time.Time
- func GetArrayStringFromByte(ci *pgtype.ConnInfo, src []byte, name string) []string
- func GetArrayTimeFromByte(ci *pgtype.ConnInfo, src []byte, name string) []time.Time
- func GetArrayTimeTimeFromByte(ci *pgtype.ConnInfo, src []byte, name string) []time.Time
- func GetBoolFromByte(ci *pgtype.ConnInfo, src []byte, name string) bool
- func GetDateFromByte(src []byte, name string) time.Time
- func GetFloat32FromByte(ci *pgtype.ConnInfo, src []byte, name string) float32
- func GetFloat64FromByte(ci *pgtype.ConnInfo, src []byte, name string) float64
- func GetInetFromByte(ci *pgtype.ConnInfo, src []byte, name string) pgtype.Inet
- func GetInt16FromByte(ci *pgtype.ConnInfo, src []byte, name string) int16
- func GetInt32FromByte(ci *pgtype.ConnInfo, src []byte, name string) int32
- func GetInt64FromByte(ci *pgtype.ConnInfo, src []byte, name string) int64
- func GetIntervalFromByte(ci *pgtype.ConnInfo, src []byte, name string) (dto pgtype.Interval)
- func GetJsonFromByte(ci *pgtype.ConnInfo, src []byte, name string) interface{}
- func GetRawBytesFromByte(ci *pgtype.ConnInfo, src []byte, name string) (dto sql.RawBytes)
- func GetRefTimeFromByte(ci *pgtype.ConnInfo, src []byte, name string) *time.Time
- func GetScanner[T sql.Scanner](ci *pgtype.ConnInfo, src []byte, name string, dto T) T
- func GetSqlNullInt32FromByte(ci *pgtype.ConnInfo, src []byte, name string) sql.NullInt32
- func GetSqlNullStringFromByte(ci *pgtype.ConnInfo, src []byte, name string) sql.NullString
- func GetStringFromByte(ci *pgtype.ConnInfo, src []byte, name string) string
- func GetTextDecoder[T pgtype.TextDecoder](ci *pgtype.ConnInfo, src []byte, name string, dto T) T
- func GetTimeFromByte(ci *pgtype.ConnInfo, src []byte, name string) time.Time
- func GetTimeTimeFromByte(ci *pgtype.ConnInfo, src []byte, name string) time.Time
- func SetLogLevel(lvl string) pgx.LogLevel
- func TrimQuotes(src []byte) string
- func UdtNameToType(udtName string) types.BasicKind
- type BuildConnOptions
- type Column
- func (col *Column) AutoIncrement() bool
- func (col *Column) BasicType() types.BasicKind
- func (col *Column) BasicTypeInfo() types.BasicInfo
- func (col *Column) CharacterMaximumLength() int
- func (col *Column) CheckAttr(colDefine string) (flags []dbEngine.FlagColumn)
- func (col *Column) Comment() string
- func (col *Column) Copy() *Column
- func (col *Column) Default() any
- func (col *Column) Foreign() *dbEngine.ForeignKey
- func (col *Column) GetFields(columns []dbEngine.Column) []any
- func (col *Column) IsArray() bool
- func (col *Column) IsNullable() bool
- func (col *Column) Name() string
- func (col *Column) Primary() bool
- func (col *Column) RefColValue(name string) any
- func (col *Column) Required() bool
- func (col *Column) SetDefault(d any)
- func (col *Column) SetNullable(f bool)
- func (col *Column) Table() dbEngine.Table
- func (col *Column) Type() string
- func (col *Column) UserDefinedType() *dbEngine.Types
- type Conn
- func (c *Conn) ExecDDL(ctx context.Context, sql string, args ...any) error
- func (c *Conn) GetNotice(conn *pgxpool.Conn) (n *pgconn.Notice, ok bool)
- func (c *Conn) GetRoutines(ctx context.Context, dbTypes map[string]dbEngine.Types, ...) (routines map[string]dbEngine.Routine, err error)
- func (c *Conn) GetSchema(ctx context.Context, cfg *dbEngine.CfgDB) (map[string]*string, map[string]dbEngine.Table, map[string]dbEngine.Routine, ...)
- func (c *Conn) GetStat() string
- func (c *Conn) GetTablesProp(ctx context.Context, dbTypes map[string]dbEngine.Types, cfg *dbEngine.CfgDB) (map[string]dbEngine.Table, error)
- func (c *Conn) InitConn(ctx context.Context, dbURL string) error
- func (c *Conn) LastRowAffected() int64
- func (c *Conn) NewTable(name, typ string) dbEngine.Table
- func (c *Conn) NewTableWithCheck(ctx context.Context, name string) (*Table, error)
- func (c *Conn) SelectAndPerformRaw(ctx context.Context, each dbEngine.FncRawRow, sql string, args ...any) error
- func (c *Conn) SelectAndRunEach(ctx context.Context, each dbEngine.FncEachRow, sql string, args ...any) error
- func (c *Conn) SelectAndScanEach(ctx context.Context, each func() error, rowValue dbEngine.RowScanner, ...) error
- func (c *Conn) SelectOneAndScan(ctx context.Context, rowValues any, sql string, args ...any) (err error)
- func (c *Conn) SelectToMap(ctx context.Context, sql string, args ...any) (map[string]any, error)
- func (c *Conn) SelectToMaps(ctx context.Context, sql string, args ...any) ([]map[string]any, error)
- func (c *Conn) SelectToMultiDimension(ctx context.Context, sql string, args ...any) (rows [][]any, cols []dbEngine.Column, err error)
- func (c *Conn) StartChannels()
- type FncAcqu
- type FncConn
- type Numeric
- func (src *Numeric) AssignTo(dst interface{}) error
- func (dst *Numeric) DecodeBinary(ci *pgtype.ConnInfo, src []byte) error
- func (dst *Numeric) DecodeText(ci *pgtype.ConnInfo, src []byte) error
- func (src Numeric) EncodeText(ci *pgtype.ConnInfo, buf []byte) ([]byte, error)
- func (src *Numeric) Float64() float64
- func (dst *Numeric) Set(src interface{}) error
- type PgxRoutineParams
- type Routine
- func (r *Routine) BuildSql(Options ...dbEngine.BuildSqlOptions) (string, []any, error)
- func (r *Routine) Call(ctx context.Context, args ...any) error
- func (r *Routine) Columns() []dbEngine.Column
- func (r *Routine) GetFields(columns []dbEngine.Column) []any
- func (r *Routine) GetParams(ctx context.Context, types map[string]dbEngine.Types, ...) error
- func (r *Routine) Name() string
- func (r *Routine) Overlay() dbEngine.Routine
- func (r *Routine) Params() []dbEngine.Column
- func (r *Routine) ReturnType() string
- func (r *Routine) Select(ctx context.Context, args ...any) error
- func (r *Routine) SelectAndRunEach(ctx context.Context, each dbEngine.FncEachRow, ...) error
- func (r *Routine) SelectAndScanEach(ctx context.Context, each func() error, row dbEngine.RowScanner, ...) error
- func (r *Routine) SelectOneAndScan(ctx context.Context, row any, Options ...dbEngine.BuildSqlOptions) error
- type Table
- func (t *Table) Columns() []dbEngine.Column
- func (t *Table) Comment() string
- func (t *Table) Delete(ctx context.Context, Options ...dbEngine.BuildSqlOptions) (int64, error)
- func (t *Table) DoCopy(ctx context.Context, src pgx.CopyFromSource, columns ...string) (int64, error)
- func (t *Table) FindColumn(name string) dbEngine.Column
- func (t *Table) FindIndex(name string) *dbEngine.Index
- func (t *Table) GetColumns(ctx context.Context, dbTypes map[string]dbEngine.Types) error
- func (t *Table) GetFields(columns []dbEngine.Column) []any
- func (t *Table) GetIndexes(ctx context.Context) error
- func (t *Table) Indexes() dbEngine.Indexes
- func (t *Table) Insert(ctx context.Context, Options ...dbEngine.BuildSqlOptions) (int64, error)
- func (t *Table) Name() string
- func (t *Table) ReReadColumn(ctx context.Context, name string) dbEngine.Column
- func (t *Table) Select(ctx context.Context, Options ...dbEngine.BuildSqlOptions) error
- func (t *Table) SelectAndRunEach(ctx context.Context, each dbEngine.FncEachRow, ...) error
- func (t *Table) SelectAndScanEach(ctx context.Context, each func() error, row dbEngine.RowScanner, ...) error
- func (t *Table) SelectOneAndScan(ctx context.Context, row any, Options ...dbEngine.BuildSqlOptions) error
- func (t *Table) Update(ctx context.Context, Options ...dbEngine.BuildSqlOptions) (int64, error)
- func (t *Table) Upsert(ctx context.Context, Options ...dbEngine.BuildSqlOptions) (int64, error)
Constants ¶
const ( ROUTINE_TYPE_PROC = "PROCEDURE" ROUTINE_TYPE_FUNC = "FUNCTION" )
ROUTINE_TYPE_PROC & ROUTINE_TYPE_FUNC are named POsqgreSQL routine
Variables ¶
var ( ErrUnknownType = errors.New("Can't define unknown type!") ErrUnknownRoutineType = errors.New("Can't add routine unknown type!") ErrFunctionWithoutResultType = errors.New("Can't add function without results type!") )
ErrUnknownRoutineType, ErrFunctionWithoutResultType are some errors
Functions ¶
func GetArrayByteFromByte ¶ added in v1.1.45
GetArrayByteFromByte convert data from src into sql.RawBytes
func GetArrayFloat32FromByte ¶ added in v1.1.45
GetFloat32FromByte convert data from src into float32
func GetArrayFloat64FromByte ¶ added in v1.1.45
GetFloat64FromByte convert data from src into float64
func GetArrayInt16FromByte ¶ added in v1.1.26
GetArrayInt16FromByte convert data from src into []int16
func GetArrayInt32FromByte ¶ added in v1.1.26
GetArrayInt32FromByte convert data from src into []int32
func GetArrayInt64FromByte ¶ added in v1.1.26
GetArrayInt64FromByte convert data from src into []int64
func GetArrayRefTimeFromByte ¶ added in v1.1.45
GetArrayTimeFromByte convert data from src into []time.Time
func GetArrayStringFromByte ¶ added in v1.1.36
GetArrayStringFromByte convert data from src into []string
func GetArrayTimeFromByte ¶ added in v1.1.11
GetArrayTimeFromByte convert data from src into []time.Time
func GetArrayTimeTimeFromByte ¶ added in v1.1.45
GetArrayTimeTimeFromByte convert data from src into []time.Time (alias for GetArrayTimeFromByte)
func GetBoolFromByte ¶ added in v1.1.11
GetBoolFromByte convert data from src into bool
func GetDateFromByte ¶ added in v1.1.9
GetDateFromByte convert date from src into time.Tome
func GetFloat32FromByte ¶ added in v1.1.45
GetFloat32FromByte convert data from src into float32
func GetFloat64FromByte ¶ added in v1.1.9
GetFloat64FromByte convert data from src into float64
func GetInetFromByte ¶ added in v1.1.11
GetInetFromByte convert data from src into pgtype.Inet
func GetInt16FromByte ¶ added in v1.1.9
GetInt16FromByte convert data from src into int16
func GetInt32FromByte ¶ added in v1.1.9
GetInt32FromByte convert data from src into int32
func GetInt64FromByte ¶ added in v1.1.9
GetInt64FromByte convert data from src into int64
func GetIntervalFromByte ¶ added in v1.1.19
GetIntervalFromByte convert data from src into []time.Time
func GetJsonFromByte ¶ added in v1.1.11
GetJsonFromByte convert data from src into json
func GetRawBytesFromByte ¶ added in v1.1.41
GetRawBytesFromByte convert data from src into sql.RawBytes
func GetRefTimeFromByte ¶ added in v1.1.11
GetRefTimeFromByte convert data from src into *time.Time
func GetScanner ¶ added in v1.1.45
GetInt32FromByte convert data from src into int32
func GetSqlNullInt32FromByte ¶ added in v1.1.45
GetInt32FromByte convert data from src into int32
func GetSqlNullStringFromByte ¶ added in v1.1.45
GetStringFromByte convert data (As Text!) from src into string
func GetStringFromByte ¶ added in v1.1.11
GetStringFromByte convert data (As Text!) from src into string
func GetTextDecoder ¶ added in v1.1.45
func GetTimeFromByte ¶ added in v1.1.11
GetTimeFromByte convert data from src into time.Time
func GetTimeTimeFromByte ¶ added in v1.1.45
GetTimeTimeFromByte convert data from src into *time.Time (alias for GetTimeFromByte)
func SetLogLevel ¶ added in v1.0.1089
func SetLogLevel(lvl string) pgx.LogLevel
SetLogLevel set logs level DB operations
func TrimQuotes ¶ added in v1.1.11
func UdtNameToType ¶ added in v1.1.7
UdtNameToType return types.BasicKind according to psql udtName
Types ¶
type BuildConnOptions ¶ added in v1.1.53
type BuildConnOptions func(route *Conn)
BuildRouteOptions implement 'Functional Option' pattern for ApiRoute settings
func AfterConnect ¶ added in v1.1.53
func AfterConnect(fnc FncConn) BuildConnOptions
AfterConnect set custom AfterConnect method on ApiRoute
func BeforeAcquire ¶ added in v1.1.53
func BeforeAcquire(fnc FncAcqu) BuildConnOptions
BeforeAcquire set same custom method on ApiRoute
func ChannelHandler ¶ added in v1.1.53
func ChannelHandler(fnc pgconn.NotificationHandler) BuildConnOptions
ChannelHandler set same custom method on ApiRoute
func Channels ¶ added in v1.1.53
func Channels(channels ...string) BuildConnOptions
NoticeHandler set same custom method on ApiRoute
func NoticeHandler ¶ added in v1.1.53
func NoticeHandler(fnc pgconn.NoticeHandler) BuildConnOptions
NoticeHandler set same custom method on ApiRoute
type Column ¶
type Column struct { DataType string CharacterSetName string UdtName string PrimaryKey bool Constraints map[string]*dbEngine.ForeignKey IsHidden bool Position int32 UserDefined *dbEngine.Types // contains filtered or unexported fields }
Column implement store data of column of table
func NewColumn ¶
func NewColumn( table *Table, name string, dataType string, colDefault any, isNullable bool, characterSetName string, comment string, udtName string, characterMaximumLength int, primaryKey bool, isHidden bool, ) *Column
NewColumn create new column with many properties
func NewColumnForTableBuf ¶ added in v1.0.1141
NewColumnForTableBuf create Column for scanning operation of Table
func NewColumnPone ¶
NewColumnPone create new column with several properties
func (*Column) AutoIncrement ¶
AutoIncrement return true if column is autoincrement
func (*Column) BasicTypeInfo ¶
BasicTypeInfo of columns value
func (*Column) CharacterMaximumLength ¶
CharacterMaximumLength return max of length text columns
func (*Column) CheckAttr ¶
func (col *Column) CheckAttr(colDefine string) (flags []dbEngine.FlagColumn)
CheckAttr check attributes of column on DB schema according to ddl-file
func (*Column) Foreign ¶ added in v1.0.1141
func (col *Column) Foreign() *dbEngine.ForeignKey
Foreign return first foreign key of column
func (*Column) RefColValue ¶ added in v1.0.1141
RefColValue referral of column property 'name'
func (*Column) SetDefault ¶ added in v1.0.1060
SetDefault set default value into column
func (*Column) SetNullable ¶
SetNullable set nullable flag of column
func (*Column) UserDefinedType ¶ added in v1.1.41
UserDefinedType return define type
type Conn ¶
type Conn struct { *pgxpool.Pool *pgxpool.Config AfterConnect FncConn BeforeAcquire FncAcqu ChannelHandler pgconn.NotificationHandler NoticeHandler pgconn.NoticeHandler NoticeMap map[uint32]*pgconn.Notice Cancel context.CancelFunc // contains filtered or unexported fields }
Conn implement connection to DB over pgx
func NewConn ¶
func NewConn(afterConnect FncConn, beforeAcquire FncAcqu, noticeHandler pgconn.NoticeHandler, channels ...string) *Conn
NewConn create new instance
func NewConnWithOptions ¶ added in v1.1.53
func NewConnWithOptions(options ...BuildConnOptions) *Conn
NewConnWithOptions create new instance
func (*Conn) GetRoutines ¶ added in v1.0.1025
func (c *Conn) GetRoutines(ctx context.Context, dbTypes map[string]dbEngine.Types, tables map[string]dbEngine.Table, cfg *dbEngine.CfgDB) (routines map[string]dbEngine.Routine, err error)
GetRoutines get properties of DB routines & returns them as map
func (*Conn) GetSchema ¶
func (c *Conn) GetSchema(ctx context.Context, cfg *dbEngine.CfgDB) (map[string]*string, map[string]dbEngine.Table, map[string]dbEngine.Routine, map[string]dbEngine.Types, error)
GetSchema read DB schema & store it
func (*Conn) GetTablesProp ¶
func (c *Conn) GetTablesProp(ctx context.Context, dbTypes map[string]dbEngine.Types, cfg *dbEngine.CfgDB) (map[string]dbEngine.Table, error)
GetTablesProp populate tables schemas data
func (*Conn) LastRowAffected ¶ added in v1.0.1092
LastRowAffected return number of insert/deleted/updated rows
func (*Conn) NewTableWithCheck ¶ added in v1.1.15
NewTableWithCheck create new Table with name, check the table from schema, populate columns and indexes
func (*Conn) SelectAndPerformRaw ¶ added in v1.0.1146
func (c *Conn) SelectAndPerformRaw(ctx context.Context, each dbEngine.FncRawRow, sql string, args ...any) error
SelectAndPerformRaw run sql with args & run each every row
func (*Conn) SelectAndRunEach ¶
func (c *Conn) SelectAndRunEach(ctx context.Context, each dbEngine.FncEachRow, sql string, args ...any) error
SelectAndRunEach run sql with args and performs each every row of query results
func (*Conn) SelectAndScanEach ¶
func (c *Conn) SelectAndScanEach(ctx context.Context, each func() error, rowValue dbEngine.RowScanner, sql string, args ...any) error
SelectAndScanEach run sql with args return every row into rowValues & run each
func (*Conn) SelectOneAndScan ¶ added in v1.0.1038
func (c *Conn) SelectOneAndScan(ctx context.Context, rowValues any, sql string, args ...any) (err error)
SelectOneAndScan run sql with args return rows into rowValues
func (*Conn) SelectToMap ¶ added in v1.0.1038
SelectToMap run sql with args return rows as map[{name_column}] case of executed - gets one record
func (*Conn) SelectToMaps ¶ added in v1.0.1038
SelectToMaps run sql with args return rows as slice of map[{name_column}]
func (*Conn) SelectToMultiDimension ¶ added in v1.0.1038
func (c *Conn) SelectToMultiDimension(ctx context.Context, sql string, args ...any) ( rows [][]any, cols []dbEngine.Column, err error)
SelectToMultiDimension run sql with args and return rows (slice of record) and columns
func (*Conn) StartChannels ¶
func (c *Conn) StartChannels()
StartChannels starts listeners of PSQL channels according to list of channels
type Numeric ¶ added in v1.0.1151
Numeric expanded pgtype.Numeric
func GetNumericFromByte ¶ added in v1.1.11
GetNumericFromByte convert data from src into Numeric
func NewNumericFromBytes ¶ added in v1.0.11562
NewNumericFromBytes create Numeric from bytes
func NewNumericFromFloat64 ¶ added in v1.0.1155
NewNumericFromFloat64 create Numeric with float value
func NewNumericNull ¶ added in v1.0.1151
func NewNumericNull() Numeric
NewNumericNull create Numeric with NULL
func (*Numeric) DecodeBinary ¶ added in v1.0.1151
DecodeBinary expand pgtype.Numeric.DecodeBinary
func (*Numeric) DecodeText ¶ added in v1.0.1151
DecodeText expand pgtype.Numeric.DecodeText()
func (Numeric) EncodeText ¶ added in v1.0.11561
EncodeText expand pgtype.Numeric.EncodeText()
type PgxRoutineParams ¶
PgxRoutineParams consist data of DB routines param
type Routine ¶
type Routine struct { ID int Comment string Type string DataType string UdtName string // contains filtered or unexported fields }
Routine consist data of DB routine and operation for reading it and perform query
func (*Routine) BuildSql ¶ added in v1.0.1093
BuildSql create sql query & arg for call conn.Select...
func (*Routine) GetParams ¶
func (r *Routine) GetParams(ctx context.Context, types map[string]dbEngine.Types, tables map[string]dbEngine.Table) error
GetParams requests parameters of routine & split them according to IN/OUT
func (*Routine) ReturnType ¶ added in v1.0.1147
ReturnType get type of routine result
func (*Routine) SelectAndRunEach ¶ added in v1.0.1027
func (r *Routine) SelectAndRunEach(ctx context.Context, each dbEngine.FncEachRow, Options ...dbEngine.BuildSqlOptions) error
SelectAndRunEach run sql of table with Options & performs each every row of query results
func (*Routine) SelectAndScanEach ¶ added in v1.0.1027
func (r *Routine) SelectAndScanEach(ctx context.Context, each func() error, row dbEngine.RowScanner, Options ...dbEngine.BuildSqlOptions) error
SelectAndScanEach run sql of table with Options & return every row into rowValues & run each
func (*Routine) SelectOneAndScan ¶ added in v1.0.1103
func (r *Routine) SelectOneAndScan(ctx context.Context, row any, Options ...dbEngine.BuildSqlOptions) error
SelectOneAndScan run sqlof table with Options & return rows into rowValues
type Table ¶
Table implement dbEngine interface Table for PostgreSQL
func (*Table) DoCopy ¶ added in v1.0.1151
func (t *Table) DoCopy(ctx context.Context, src pgx.CopyFromSource, columns ...string) (int64, error)
DoCopy run CopyFrom PSQL use src interface
func (*Table) FindColumn ¶
FindColumn return column 'name' on Table or nil
func (*Table) GetColumns ¶
GetColumns получение значений полей для форматирования данных получение значений полей для таблицы
func (*Table) GetIndexes ¶ added in v1.0.1095
GetIndexes collect index of table
func (*Table) ReReadColumn ¶ added in v1.0.1040
ReReadColumn renew properties of column 'name'
func (*Table) SelectAndRunEach ¶
func (t *Table) SelectAndRunEach(ctx context.Context, each dbEngine.FncEachRow, Options ...dbEngine.BuildSqlOptions) error
SelectAndRunEach run sql of table with Options & performs each every row of query results
func (*Table) SelectAndScanEach ¶
func (t *Table) SelectAndScanEach(ctx context.Context, each func() error, row dbEngine.RowScanner, Options ...dbEngine.BuildSqlOptions) error
SelectAndScanEach run sql of table with Options & return every row into rowValues & run each
func (*Table) SelectOneAndScan ¶ added in v1.0.1088
func (t *Table) SelectOneAndScan(ctx context.Context, row any, Options ...dbEngine.BuildSqlOptions) error
SelectOneAndScan run sqlof table with Options & return rows into rowValues