postgres

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBodyEmpty = errors.New("body is empty")

ErrBodyEmpty err throw when body is empty

Functions

func AddDatabaseToPool added in v1.0.10

func AddDatabaseToPool(name string, DB *sqlx.DB)

AddDatabaseToPool add connection to pool

func ClearStmt added in v1.0.10

func ClearStmt()

ClearStmt used to reset the cache and allow multiple tests

func Get added in v1.0.10

func Get() (*sqlx.DB, error)

Get get postgres connection

func GetDatabase added in v1.0.10

func GetDatabase() string

GetDatabase get current database in use

func GetPool added in v1.0.10

func GetPool() *connection.Pool

GetPool of connection

func GetQueryOperator

func GetQueryOperator(op string) (string, error)

GetQueryOperator identify operator on a join

func GetURI added in v1.0.10

func GetURI(DBName string) string

GetURI postgres connection URI

func Load added in v1.0.10

func Load()

Load postgres

func MustGet added in v1.0.10

func MustGet() *sqlx.DB

MustGet get postgres connection

func NormalizeGroupFunction added in v1.0.10

func NormalizeGroupFunction(paramValue string) (groupFuncSQL string, err error)

NormalizeGroupFunction normalize url params values to sql group functions

func Prepare added in v1.0.10

func Prepare(db *sqlx.DB, SQL string) (stmt *sql.Stmt, err error)

Prepare statement func

func PrepareTx added in v1.0.10

func PrepareTx(tx *sql.Tx, SQL string) (stmt *sql.Stmt, err error)

PrepareTx statement func

func SetDatabase added in v1.0.10

func SetDatabase(name string)

SetDatabase set current database in use

func WriteSQL

func WriteSQL(sql string, values []interface{}) (sc adapters.Scanner)

WriteSQL perform INSERT's, UPDATE's, DELETE's operations

Types

type Postgres added in v1.0.10

type Postgres struct {
}

Postgres adapter postgresql

func (*Postgres) BatchInsertCopy added in v1.0.10

func (adapter *Postgres) BatchInsertCopy(dbname, schema, table string, keys []string, values ...interface{}) (sc adapters.Scanner)

BatchInsertCopy execute batch insert sql into a table unsing copy

func (*Postgres) BatchInsertValues added in v1.0.10

func (adapter *Postgres) BatchInsertValues(SQL string, values ...interface{}) (sc adapters.Scanner)

BatchInsertValues execute batch insert sql into a table unsing multi values

func (*Postgres) CountByRequest added in v1.0.10

func (adapter *Postgres) CountByRequest(req *http.Request) (countQuery string, err error)

CountByRequest implements COUNT(fields) OPERTATION

func (*Postgres) DatabaseClause added in v1.0.10

func (adapter *Postgres) DatabaseClause(req *http.Request) (query string, hasCount bool)

DatabaseClause return a SELECT `query`

func (*Postgres) DatabaseOrderBy added in v1.0.10

func (adapter *Postgres) DatabaseOrderBy(order string, hasCount bool) (orderBy string)

DatabaseOrderBy generate database order by

func (*Postgres) DatabaseWhere added in v1.0.10

func (adapter *Postgres) DatabaseWhere(requestWhere string) (whereSyntax string)

DatabaseWhere generate database where syntax

func (*Postgres) Delete added in v1.0.10

func (adapter *Postgres) Delete(SQL string, params ...interface{}) (sc adapters.Scanner)

Delete execute delete sql into a table

func (*Postgres) DeleteSQL added in v1.0.10

func (adapter *Postgres) DeleteSQL(database string, schema string, table string) string

DeleteSQL generate delete sql

func (*Postgres) DeleteWithTransaction added in v1.0.10

func (adapter *Postgres) DeleteWithTransaction(tx *sql.Tx, SQL string, params ...interface{}) (sc adapters.Scanner)

DeleteWithTransaction execute delete sql into a table

func (*Postgres) DistinctClause added in v1.0.10

func (adapter *Postgres) DistinctClause(r *http.Request) (distinctQuery string, err error)

DistinctClause get params in request to add distinct clause

func (*Postgres) ExecuteScripts added in v1.0.10

func (adapter *Postgres) ExecuteScripts(method, sql string, values []interface{}) (sc adapters.Scanner)

ExecuteScripts run sql templates created by users

func (*Postgres) FieldsPermissions added in v1.0.10

func (adapter *Postgres) FieldsPermissions(r *http.Request, table string, op string) (fields []string, err error)

FieldsPermissions get fields permissions based in prest configuration

func (*Postgres) GetDatabase added in v1.0.10

func (adapter *Postgres) GetDatabase() string

GetDatabase returns the current DB name

func (*Postgres) GetScript added in v1.0.10

func (adapter *Postgres) GetScript(verb, folder, scriptName string) (script string, err error)

GetScript get SQL template file

func (*Postgres) GetTransaction added in v1.0.10

func (adapter *Postgres) GetTransaction() (tx *sql.Tx, err error)

GetTransaction get transaction

func (*Postgres) GroupByClause added in v1.0.10

func (adapter *Postgres) GroupByClause(r *http.Request) (groupBySQL string)

GroupByClause get params in request to add group by clause

func (*Postgres) Insert added in v1.0.10

func (adapter *Postgres) Insert(SQL string, params ...interface{}) (sc adapters.Scanner)

Insert execute insert sql into a table

func (*Postgres) InsertSQL added in v1.0.10

func (adapter *Postgres) InsertSQL(database string, schema string, table string, names string, placeholders string) string

InsertSQL generate insert sql

func (*Postgres) InsertWithTransaction added in v1.0.10

func (adapter *Postgres) InsertWithTransaction(tx *sql.Tx, SQL string, params ...interface{}) (sc adapters.Scanner)

InsertWithTransaction execute insert sql into a table

func (*Postgres) JoinByRequest added in v1.0.10

func (adapter *Postgres) JoinByRequest(r *http.Request) (values []string, err error)

JoinByRequest implements join in queries

func (*Postgres) OrderByRequest added in v1.0.10

func (adapter *Postgres) OrderByRequest(r *http.Request) (values string, err error)

OrderByRequest implements ORDER BY in queries

func (*Postgres) PaginateIfPossible added in v1.0.10

func (adapter *Postgres) PaginateIfPossible(r *http.Request) (paginatedQuery string, err error)

PaginateIfPossible func

func (*Postgres) ParseBatchInsertRequest added in v1.0.10

func (adapter *Postgres) ParseBatchInsertRequest(r *http.Request) (colsName string, placeholders string, values []interface{}, err error)

ParseBatchInsertRequest create insert SQL to batch request

func (*Postgres) ParseInsertRequest added in v1.0.10

func (adapter *Postgres) ParseInsertRequest(r *http.Request) (colsName string, colsValue string, values []interface{}, err error)

ParseInsertRequest create insert SQL

func (*Postgres) ParseScript added in v1.0.10

func (adapter *Postgres) ParseScript(scriptPath string, templateData map[string]interface{}) (sqlQuery string, values []interface{}, err error)

ParseScript use values sent by users and add on script

func (*Postgres) Query added in v1.0.10

func (adapter *Postgres) Query(SQL string, params ...interface{}) (sc adapters.Scanner)

Query process queries

func (*Postgres) QueryCount added in v1.0.10

func (adapter *Postgres) QueryCount(SQL string, params ...interface{}) (sc adapters.Scanner)

QueryCount process queries with count

func (*Postgres) ReturningByRequest added in v1.0.10

func (adapter *Postgres) ReturningByRequest(r *http.Request) (returningSyntax string, err error)

ReturningByRequest create interface for queries + returning

func (*Postgres) SchemaClause added in v1.0.10

func (adapter *Postgres) SchemaClause(req *http.Request) (query string, hasCount bool)

SchemaClause return a SELECT `query`

func (*Postgres) SchemaOrderBy added in v1.0.10

func (adapter *Postgres) SchemaOrderBy(order string, hasCount bool) (orderBy string)

SchemaOrderBy generate schema order by

func (*Postgres) SchemaTablesClause added in v1.0.10

func (adapter *Postgres) SchemaTablesClause() (query string)

SchemaTablesClause generate schema tables clause

func (*Postgres) SchemaTablesOrderBy added in v1.0.10

func (adapter *Postgres) SchemaTablesOrderBy(order string) (orderBy string)

SchemaTablesOrderBy generate schema tables order by

func (*Postgres) SchemaTablesWhere added in v1.0.10

func (adapter *Postgres) SchemaTablesWhere(requestWhere string) (whereSyntax string)

SchemaTablesWhere generate schema tables where syntax

func (*Postgres) SelectFields added in v1.0.10

func (adapter *Postgres) SelectFields(fields []string) (sql string, err error)

SelectFields query

func (*Postgres) SelectSQL added in v1.0.10

func (adapter *Postgres) SelectSQL(selectStr string, database string, schema string, table string) string

SelectSQL generate select sql

func (*Postgres) SetByRequest added in v1.0.10

func (adapter *Postgres) SetByRequest(r *http.Request, initialPlaceholderID int) (setSyntax string, values []interface{}, err error)

SetByRequest create a set clause for SQL

func (*Postgres) SetDatabase added in v1.0.10

func (adapter *Postgres) SetDatabase(name string)

SetDatabase set the current database name in use

func (*Postgres) ShowTable added in v1.0.10

func (adapter *Postgres) ShowTable(schema, table string) adapters.Scanner

ShowTable shows table structure

func (*Postgres) TableClause added in v1.0.10

func (adapter *Postgres) TableClause() (query string)

TableClause generate table clause

func (*Postgres) TableOrderBy added in v1.0.10

func (adapter *Postgres) TableOrderBy(order string) (orderBy string)

TableOrderBy generate table order by

func (*Postgres) TablePermissions added in v1.0.10

func (adapter *Postgres) TablePermissions(table string, op string) (access bool)

TablePermissions get tables permissions based in prest configuration

func (*Postgres) TableWhere added in v1.0.10

func (adapter *Postgres) TableWhere(requestWhere string) (whereSyntax string)

TableWhere generate table where syntax

func (*Postgres) Update added in v1.0.10

func (adapter *Postgres) Update(SQL string, params ...interface{}) (sc adapters.Scanner)

Update execute update sql into a table

func (*Postgres) UpdateSQL added in v1.0.10

func (adapter *Postgres) UpdateSQL(database string, schema string, table string, setSyntax string) string

UpdateSQL generate update sql

func (*Postgres) UpdateWithTransaction added in v1.0.10

func (adapter *Postgres) UpdateWithTransaction(tx *sql.Tx, SQL string, params ...interface{}) (sc adapters.Scanner)

UpdateWithTransaction execute update sql into a table

func (*Postgres) WhereByRequest added in v1.0.10

func (adapter *Postgres) WhereByRequest(r *http.Request, initialPlaceholderID int) (whereSyntax string, values []interface{}, err error)

WhereByRequest create interface for queries + where

type Stmt added in v1.0.10

type Stmt struct {
	Mtx        *sync.Mutex
	PrepareMap map[string]*sql.Stmt
}

Stmt statement representation

func GetStmt added in v1.0.10

func GetStmt() *Stmt

GetStmt get statement

func (*Stmt) Prepare added in v1.0.10

func (s *Stmt) Prepare(db *sqlx.DB, tx *sql.Tx, SQL string) (statement *sql.Stmt, err error)

Prepare statement

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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