Documentation ¶
Index ¶
- Variables
- func AddDatabaseToPool(name string, DB *sqlx.DB)
- func ClearStmt()
- func Get() (*sqlx.DB, error)
- func GetDatabase() string
- func GetPool() *connection.Pool
- func GetQueryOperator(op string) (string, error)
- func GetURI(DBName string) string
- func Load()
- func MustGet() *sqlx.DB
- func NormalizeGroupFunction(paramValue string) (groupFuncSQL string, err error)
- func Prepare(db *sqlx.DB, SQL string) (stmt *sql.Stmt, err error)
- func PrepareTx(tx *sql.Tx, SQL string) (stmt *sql.Stmt, err error)
- func SetDatabase(name string)
- func WriteSQL(sql string, values []interface{}) (sc adapters.Scanner)
- func WriteSQLCtx(ctx context.Context, sql string, values []interface{}) (sc adapters.Scanner)
- type Postgres
- func (adapter *Postgres) BatchInsertCopy(dbname, schema, table string, keys []string, values ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) BatchInsertCopyCtx(ctx context.Context, dbname, schema, table string, keys []string, ...) (sc adapters.Scanner)
- func (adapter *Postgres) BatchInsertValues(SQL string, values ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) BatchInsertValuesCtx(ctx context.Context, SQL string, values ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) CountByRequest(req *http.Request) (countQuery string, err error)
- func (adapter *Postgres) DatabaseClause(req *http.Request) (query string, hasCount bool)
- func (adapter *Postgres) DatabaseOrderBy(order string, hasCount bool) (orderBy string)
- func (adapter *Postgres) DatabaseWhere(requestWhere string) (whereSyntax string)
- func (adapter *Postgres) Delete(SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) DeleteCtx(ctx context.Context, SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) DeleteSQL(database string, schema string, table string) string
- func (adapter *Postgres) DeleteWithTransaction(tx *sql.Tx, SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) DistinctClause(r *http.Request) (distinctQuery string, err error)
- func (adapter *Postgres) ExecuteScripts(method, sql string, values []interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) ExecuteScriptsCtx(ctx context.Context, method, sql string, values []interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) FieldsPermissions(r *http.Request, table string, op string) (fields []string, err error)
- func (adapter *Postgres) GetDatabase() string
- func (adapter *Postgres) GetScript(verb, folder, scriptName string) (script string, err error)
- func (adapter *Postgres) GetTransaction() (tx *sql.Tx, err error)
- func (adapter *Postgres) GetTransactionCtx(ctx context.Context) (tx *sql.Tx, err error)
- func (adapter *Postgres) GroupByClause(r *http.Request) (groupBySQL string)
- func (adapter *Postgres) Insert(SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) InsertCtx(ctx context.Context, SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) InsertSQL(database string, schema string, table string, names string, ...) string
- func (adapter *Postgres) InsertWithTransaction(tx *sql.Tx, SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) JoinByRequest(r *http.Request) (values []string, err error)
- func (adapter *Postgres) OrderByRequest(r *http.Request) (values string, err error)
- func (adapter *Postgres) PaginateIfPossible(r *http.Request) (paginatedQuery string, err error)
- func (adapter *Postgres) ParseBatchInsertRequest(r *http.Request) (colsName string, placeholders string, values []interface{}, err error)
- func (adapter *Postgres) ParseInsertRequest(r *http.Request) (colsName string, colsValue string, values []interface{}, err error)
- func (adapter *Postgres) ParseScript(scriptPath string, templateData map[string]interface{}) (sqlQuery string, values []interface{}, err error)
- func (adapter *Postgres) Query(SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) QueryCount(SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) QueryCountCtx(ctx context.Context, SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) QueryCtx(ctx context.Context, SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) ReturningByRequest(r *http.Request) (returningSyntax string, err error)
- func (adapter *Postgres) SchemaClause(req *http.Request) (query string, hasCount bool)
- func (adapter *Postgres) SchemaOrderBy(order string, hasCount bool) (orderBy string)
- func (adapter *Postgres) SchemaTablesClause() (query string)
- func (adapter *Postgres) SchemaTablesOrderBy(order string) (orderBy string)
- func (adapter *Postgres) SchemaTablesWhere(requestWhere string) (whereSyntax string)
- func (adapter *Postgres) SelectFields(fields []string) (sql string, err error)
- func (adapter *Postgres) SelectSQL(selectStr string, database string, schema string, table string) string
- func (adapter *Postgres) SetByRequest(r *http.Request, initialPlaceholderID int) (setSyntax string, values []interface{}, err error)
- func (adapter *Postgres) SetDatabase(name string)
- func (adapter *Postgres) ShowTable(schema, table string) adapters.Scanner
- func (adapter *Postgres) ShowTableCtx(ctx context.Context, schema, table string) adapters.Scanner
- func (adapter *Postgres) TableClause() (query string)
- func (adapter *Postgres) TableOrderBy(order string) (orderBy string)
- func (adapter *Postgres) TablePermissions(table string, op string) (access bool)
- func (adapter *Postgres) TableWhere(requestWhere string) (whereSyntax string)
- func (adapter *Postgres) Update(SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) UpdateCtx(ctx context.Context, SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) UpdateSQL(database string, schema string, table string, setSyntax string) string
- func (adapter *Postgres) UpdateWithTransaction(tx *sql.Tx, SQL string, params ...interface{}) (sc adapters.Scanner)
- func (adapter *Postgres) WhereByRequest(r *http.Request, initialPlaceholderID int) (whereSyntax string, values []interface{}, err error)
- type Stmt
Constants ¶
This section is empty.
Variables ¶
var ( ErrJoinInvalidNumberOfArgs = errors.New("invalid number of arguments in join statement") ErrInvalidIdentifier = errors.New("invalid identifier") ErrInvalidJoinClause = errors.New("invalid join clause") ErrMustSelectOneField = errors.New("you must select at least one field") ErrNoTableName = errors.New("unable to find table name") ErrInvalidOperator = errors.New("invalid operator") ErrInvalidGroupFn = errors.New("invalid group function") // ErrBodyEmpty err throw when body is empty ErrBodyEmpty = errors.New("body is empty") )
Functions ¶
func AddDatabaseToPool ¶ added in v1.4.2
AddDatabaseToPool add connection to pool
func ClearStmt ¶ added in v1.4.2
func ClearStmt()
ClearStmt used to reset the cache and allow multiple tests
func GetDatabase ¶ added in v1.4.2
func GetDatabase() string
GetDatabase get current database in use
func GetQueryOperator ¶
GetQueryOperator identify operator on a join
func NormalizeGroupFunction ¶ added in v1.4.2
NormalizeGroupFunction normalize url params values to sql group functions
func SetDatabase ¶ added in v1.4.2
func SetDatabase(name string)
SetDatabase set current database in use todo: remove when ctx is fully implemented
Types ¶
type Postgres ¶ added in v1.4.2
type Postgres struct{}
Postgres adapter postgresql
func (*Postgres) BatchInsertCopy ¶ added in v1.4.2
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) BatchInsertCopyCtx ¶ added in v1.4.2
func (adapter *Postgres) BatchInsertCopyCtx(ctx context.Context, dbname, schema, table string, keys []string, values ...interface{}) (sc adapters.Scanner)
BatchInsertCopyCtx execute batch insert sql into a table unsing copy
func (*Postgres) BatchInsertValues ¶ added in v1.4.2
BatchInsertValues execute batch insert sql into a table unsing multi values
func (*Postgres) BatchInsertValuesCtx ¶ added in v1.4.2
func (adapter *Postgres) BatchInsertValuesCtx(ctx context.Context, SQL string, values ...interface{}) (sc adapters.Scanner)
BatchInsertValuesCtx execute batch insert sql into a table unsing multi values
func (*Postgres) CountByRequest ¶ added in v1.4.2
CountByRequest implements COUNT(fields) OPERTATION
func (*Postgres) DatabaseClause ¶ added in v1.4.2
DatabaseClause return a SELECT `query`
func (*Postgres) DatabaseOrderBy ¶ added in v1.4.2
DatabaseOrderBy generate database order by
func (*Postgres) DatabaseWhere ¶ added in v1.4.2
DatabaseWhere generate database where syntax
func (*Postgres) DeleteCtx ¶ added in v1.4.2
func (adapter *Postgres) DeleteCtx(ctx context.Context, SQL string, params ...interface{}) (sc adapters.Scanner)
Delete execute delete sql into a table
func (*Postgres) DeleteWithTransaction ¶ added in v1.4.2
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.4.2
DistinctClause get params in request to add distinct clause
func (*Postgres) ExecuteScripts ¶ added in v1.4.2
func (adapter *Postgres) ExecuteScripts(method, sql string, values []interface{}) (sc adapters.Scanner)
ExecuteScripts run sql templates created by users
func (*Postgres) ExecuteScriptsCtx ¶ added in v1.4.2
func (adapter *Postgres) ExecuteScriptsCtx(ctx context.Context, method, sql string, values []interface{}) (sc adapters.Scanner)
ExecuteScriptsCtx run sql templates created by users
func (*Postgres) FieldsPermissions ¶ added in v1.4.2
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.4.2
GetDatabase returns the current DB name
func (*Postgres) GetTransaction ¶ added in v1.4.2
GetTransaction get transaction
func (*Postgres) GetTransactionCtx ¶ added in v1.4.2
GetTransactionCtx get transaction
func (*Postgres) GroupByClause ¶ added in v1.4.2
GroupByClause get params in request to add group by clause
func (*Postgres) InsertCtx ¶ added in v1.4.2
func (adapter *Postgres) InsertCtx(ctx context.Context, SQL string, params ...interface{}) (sc adapters.Scanner)
InsertCtx execute insert sql into a table
func (*Postgres) InsertSQL ¶ added in v1.4.2
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.4.2
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.4.2
JoinByRequest implements join in queries
func (*Postgres) OrderByRequest ¶ added in v1.4.2
OrderByRequest implements ORDER BY in queries
func (*Postgres) PaginateIfPossible ¶ added in v1.4.2
PaginateIfPossible when passing non-valid paging parameters (conversion to integer) the query will be made with default value
func (*Postgres) ParseBatchInsertRequest ¶ added in v1.4.2
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.4.2
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.4.2
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) QueryCount ¶ added in v1.4.2
QueryCount process queries with count
func (*Postgres) QueryCountCtx ¶ added in v1.4.2
func (adapter *Postgres) QueryCountCtx(ctx context.Context, SQL string, params ...interface{}) (sc adapters.Scanner)
QueryCount process queries with count
func (*Postgres) QueryCtx ¶ added in v1.4.2
func (adapter *Postgres) QueryCtx(ctx context.Context, SQL string, params ...interface{}) (sc adapters.Scanner)
QueryCtx process queries using the DB name from Context
allows setting timeout
func (*Postgres) ReturningByRequest ¶ added in v1.4.2
ReturningByRequest create interface for queries + returning
func (*Postgres) SchemaClause ¶ added in v1.4.2
SchemaClause return a SELECT `query`
func (*Postgres) SchemaOrderBy ¶ added in v1.4.2
SchemaOrderBy generate schema order by
func (*Postgres) SchemaTablesClause ¶ added in v1.4.2
SchemaTablesClause generate schema tables clause
func (*Postgres) SchemaTablesOrderBy ¶ added in v1.4.2
SchemaTablesOrderBy generate schema tables order by
func (*Postgres) SchemaTablesWhere ¶ added in v1.4.2
SchemaTablesWhere generate schema tables where syntax
func (*Postgres) SelectFields ¶ added in v1.4.2
SelectFields query
func (*Postgres) SelectSQL ¶ added in v1.4.2
func (adapter *Postgres) SelectSQL(selectStr string, database string, schema string, table string) string
SelectSQL generate select sql
func (*Postgres) SetByRequest ¶ added in v1.4.2
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.4.2
SetDatabase set the current database name in use
func (*Postgres) ShowTableCtx ¶ added in v1.4.2
ShowTableCtx shows table structure
func (*Postgres) TableClause ¶ added in v1.4.2
TableClause generate table clause
func (*Postgres) TableOrderBy ¶ added in v1.4.2
TableOrderBy generate table order by
func (*Postgres) TablePermissions ¶ added in v1.4.2
TablePermissions get tables permissions based in prest configuration
func (*Postgres) TableWhere ¶ added in v1.4.2
TableWhere generate table where syntax
func (*Postgres) UpdateCtx ¶ added in v1.4.2
func (adapter *Postgres) UpdateCtx(ctx context.Context, SQL string, params ...interface{}) (sc adapters.Scanner)
Update execute update sql into a table
func (*Postgres) UpdateSQL ¶ added in v1.4.2
func (adapter *Postgres) UpdateSQL(database string, schema string, table string, setSyntax string) string
UpdateSQL generate update sql