Documentation
¶
Index ¶
- func ContextOrBackground(ctx context.Context) context.Context
- func ErrConvert(field string, index int, value interface{}, to string) error
- func ParseBool(s []byte) bool
- func ParseFloat(s []byte) float64
- func ParseInt(s []byte) int64
- func ParseTime(b []byte, precision int) time.Time
- func ParseUInt(s []byte) uint64
- func QMarks(n int) string
- func Values(r sql.Rows) []driver.Value
- type Assignment
- type Assignments
- type CreateParams
- type DeleteParams
- type DropParams
- type Group
- type Groups
- type InsertParams
- type JoinParams
- type Order
- type Orders
- type Page
- type Pairing
- type SelectParams
- type StatementArger
- type TableNamer
- type UpdateParams
- type Where
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseFloat ¶
func ParseTime ¶
ParseTime parses time from mysql database zero time is a special case, since it's month is 00, which causes month out of range error.
Types ¶
type Assignment ¶
type Assignment struct {
Column string
ColumnValue interface{}
OriginalValue interface{}
}
Assignment is a struct that is used for INSERT and UPDATE/SET operations It holds column name and the value to assign.
type Assignments ¶
type Assignments []Assignment
Assignments is a list of Assignment
func (*Assignments) Add ¶
func (a *Assignments) Add(name string, columnValue interface{}, originalValue interface{})
Add adds an assignment to the list
func (Assignments) Args ¶
func (a Assignments) Args() []interface{}
Args are the list of values of the Assignment list
type CreateParams ¶
type CreateParams struct {
Table string
MarshaledTable string
// IfNotExists determines to create the table only if it does not exists
IfNotExists bool
// AutoMigrate perform auto-migration of table scheme
AutoMigrate bool
// Ctx is a context parameter for the query
// even though it is not recommended to store context in a struct, here the struct
// actually represents an arguments list, passed to a function.
Ctx context.Context
}
CreateParams holds parameters for an SQL CREATE statement
type DeleteParams ¶
type DeleteParams struct {
Table string
Where Where
// Ctx is a context parameter for the query
// even though it is not recommended to store context in a struct, here the struct
// actually represents an arguments list, passed to a function.
Ctx context.Context
}
DeleteParams holds parameters for an SQL DELETE statement
type DropParams ¶
type DropParams struct {
Table string
IfExists bool
// Ctx is a context parameter for the query
// even though it is not recommended to store context in a struct, here the struct
// actually represents an arguments list, passed to a function.
Ctx context.Context
}
DropParams holds parameters for an SQL DROP statement
type Group ¶
type Group struct {
Column string
}
Group is a struct that is used for GROUP BY operations
type InsertParams ¶
type InsertParams struct {
Table string
// Assignments are values to store in the new row
Assignments Assignments
// Ctx is a context parameter for the query
// even though it is not recommended to store context in a struct, here the struct
// actually represents an arguments list, passed to a function.
Ctx context.Context
}
InsertParams holds parameters for an SQL INSERT statement
type JoinParams ¶
type JoinParams struct {
SelectParams
Pairings []Pairing
}
JoinParams are parameters to perform a join operation Field SelectParams is used to perform select operations on the join struct's field. Pairings describe the relation between the join's fields
func (*JoinParams) TableName ¶
func (j *JoinParams) TableName(parentTable string) string
TableName creates a table name for a join operation this is useful in case several fields referencing the same table
type Order ¶
Order is a struct that is used for ORDER BY operations. It holds the column name and the order direction.
type Pairing ¶
type Pairing struct {
// Column is the column in the current table for the JOIN statement
Column string
// JoinedColumn is the column in the referenced table for the JOIN statement
JoinedColumn string
}
Pairing describe a join relation
type SelectParams ¶
type SelectParams struct {
Table string
// Columns are the selected columns for the query
Columns map[string]bool
// Joins are recursive join arguments for the query
Joins []JoinParams
// Count indicates weather a COUNT(*) column should be added to the query
Count bool
// Where is the WHERE part of the query
Where Where
// Groups are is the GROUP BY conditions for the query
Groups Groups
// Orders are the ORDER BY conditions for the query
Orders Orders
// Page is for query pagination
Page Page
// OrderedColumns store all the columns of a table
// they are defined in a specific order so the parsing of returned values from
// the SQL query will be easy.
OrderedColumns []string
// Ctx is a context parameter for the query
// even though it is not recommended to store context in a struct, here the struct
// actually represents an arguments list, passed to a function.
Ctx context.Context
}
SelectParams holds parameters for an SQL SELECT statement
func (*SelectParams) SelectAll ¶
func (p *SelectParams) SelectAll() bool
SelectAll indicates if the SelectParams should select all columns in the query string
func (*SelectParams) SelectedColumns ¶
func (p *SelectParams) SelectedColumns() []string
SelectedColumns returns a list of selected columns for a query
type StatementArger ¶
StatementArger is interface for queries. The statement and the args are given to the SQL query.
type TableNamer ¶
type TableNamer interface {
TableName() string
}
TableNamer is an interface for a model to change it's table name a struct that implements this interface will set it's SQL table name by the return value from TableName function.
type UpdateParams ¶
type UpdateParams struct {
Table string
Assignments Assignments
Where Where
// Ctx is a context parameter for the query
// even though it is not recommended to store context in a struct, here the struct
// actually represents an arguments list, passed to a function.
Ctx context.Context
}
UpdateParams holds parameters for an SQL UPDATE statement
type Where ¶
type Where interface {
StatementArger
// Or applies OR condition with another Where statement
Or(Where) Where
// And applies AND condition with another Where statement
And(Where) Where
}
Where is an API for creating WHERE statements
func NewWhereBetween ¶
NewWhereBetween returns a new 'WHERE variable BETWEEN low AND high' statement
func NewWhereIn ¶
NewWhereIn returns a new 'WHERE variable IN (...)' statement