Documentation
¶
Overview ¶
Package sql provides tools and DAOs for speaking SQL as well as managing tables migrations
Index ¶
- Variables
- func CountStringFromExpression(tableName string, columnCount string, driver string, e Enquirer, ...) (string, []interface{}, error)
- func DeleteStringFromExpression(tableName string, driver string, ex goqu.Expression) (string, []interface{}, error)
- func ExecMax(db *sql.DB, dialect string, m migrate.MigrationSource, ...) (int, error)
- func ExecMigration(db *sql.DB, dialect string, m migrate.MigrationSource, ...) (int, error)
- func GetExpressionForString(neq bool, field string, values ...string) (expression goqu.Expression)
- func GetQueryValueFor(field string, values ...string) string
- func JoinWheresWithParenthesis(wheres []string, join string) string
- func NewDAOQuery(enquirer Enquirer, converters ...common.Converter) fmt.Stringer
- func PlanMigration(db *sql.DB, dialect string, m migrate.MigrationSource, ...) ([]*migrate.PlannedMigration, *gorp.DbMap, error)
- func QueryStringFromExpression(tableName string, driver string, e Enquirer, ex goqu.Expression, ...) (string, []interface{}, error)
- func SetSchema(name string)
- func SetTable(name string)
- type BatchReceiver
- type BatchSender
- type DAO
- type Enquirer
- type ExpressionConverter
- type Expressioner
- type Handler
- type PackrBox
- type PackrMigrationSource
- type Scanner
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func CountStringFromExpression ¶ added in v1.0.2
func CountStringFromExpression(tableName string, columnCount string, driver string, e Enquirer, ex goqu.Expression, resourceExpression goqu.Expression) (string, []interface{}, error)
QueryStringFromExpression finally builds a full SELECT from a Goqu Expression
func DeleteStringFromExpression ¶ added in v1.0.2
func DeleteStringFromExpression(tableName string, driver string, ex goqu.Expression) (string, []interface{}, error)
DeleteStringFromExpression creates sql for DELETE FROM expression
func ExecMax ¶ added in v1.0.2
func ExecMax(db *sql.DB, dialect string, m migrate.MigrationSource, dir migrate.MigrationDirection, max int, prefix string) (int, error)
Execute a set of migrations
Will apply at most `max` migrations. Pass 0 for no limit (or use Exec).
Returns the number of applied migrations.
func ExecMigration ¶ added in v1.0.2
func ExecMigration(db *sql.DB, dialect string, m migrate.MigrationSource, dir migrate.MigrationDirection, prefix string) (int, error)
Execute a set of migrations
Returns the number of applied migrations.
func GetExpressionForString ¶ added in v1.0.2
GetExpressionForString creates correct goqu.Expression for field + string value
func GetQueryValueFor ¶
GetQueryValueFor field value
func JoinWheresWithParenthesis ¶
JoinConditionsWithParenthesis joins conditions using parenthesis if there are many, or no parenthesis if there is just one, and prepend the WHERE keyword to the string
func NewDAOQuery ¶
NewDAOQuery adds database functionality to a Query proto message
func PlanMigration ¶ added in v1.0.2
func PlanMigration(db *sql.DB, dialect string, m migrate.MigrationSource, dir migrate.MigrationDirection, max int, prefix string) ([]*migrate.PlannedMigration, *gorp.DbMap, error)
Plan a migration.
func QueryStringFromExpression ¶ added in v1.0.2
func QueryStringFromExpression(tableName string, driver string, e Enquirer, ex goqu.Expression, resourceExpression goqu.Expression, limit int64) (string, []interface{}, error)
QueryStringFromExpression finally builds a full SELECT from a Goqu Expression
Types ¶
type BatchSender ¶
type BatchSender interface {
Send(interface{})
Close() error
}
BatchSender interface
type DAO ¶
type DAO interface {
dao.DAO
DB() *sql.DB
Prepare(string, interface{}) error
GetStmt(string, ...interface{}) *sql.Stmt
UseExclusion()
Lock()
Unlock()
}
DAO interface definition
type Enquirer ¶
type Enquirer interface {
GetSubQueries() []*any.Any
GetOperation() service.OperationType
GetOffset() int64
GetLimit() int64
GetGroupBy() int32
GetResourcePolicyQuery() *service.ResourcePolicyQuery
fmt.Stringer
}
Enquirer interface
type ExpressionConverter ¶ added in v1.0.2
ExpressionConverter ...
type Expressioner ¶ added in v1.0.2
type Expressioner interface {
Expression(driver string) goqu.Expression
}
Expressioner ...
func NewQueryBuilder ¶ added in v1.0.2
func NewQueryBuilder(e Enquirer, c ...ExpressionConverter) Expressioner
NewQueryBuilder generates SQL request from object
type Handler ¶
Handler for the main functions of the DAO
func (*Handler) GetStmt ¶
GetStmt returns a list of all statements used by the dao
func (*Handler) Init ¶
func (h *Handler) Init(c common.ConfigValues) error
func (*Handler) Prepare ¶
Prepare the statements that can be used by the DAO
type PackrBox ¶
Avoids pulling in the packr library for everyone, mimicks the bits of packr.Box that we need.
Source Files
¶
- batch.go
- dao.go
- migrate.go
- migration.go
- query-builder.go
- query.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package index provides ready-to-use tables and DAOs for storing hierarchical data using the nested sets pattern
|
Package index provides ready-to-use tables and DAOs for storing hierarchical data using the nested sets pattern |
|
Package resources provides ready-to-use SQL schemes and DAOs for attaching resource policies to any data
|
Package resources provides ready-to-use SQL schemes and DAOs for attaching resource policies to any data |