Documentation ¶
Index ¶
- Constants
- Variables
- type Condition
- type Count
- type Delete
- type Exec
- type ExecWithReturning
- type Field
- type Field1
- type Fields
- type For
- type Insert
- type Limit
- type Offset
- type OrderBy
- type OrderByKind
- type Query
- type Returning
- type Select
- type SelectExists
- type SqlBuilder
- type Table
- type Update
- type Where
- type WhereItem
- type WhereItems
Constants ¶
View Source
const ( EQ conditionOperator = "=" // Equal (=) Operator NEQ conditionOperator = "!=" // Not Equal (!= or <>) Operator GT conditionOperator = ">" // Greater Than (>) Operator LT conditionOperator = "<" // Less Than (<) Operator GTEQ conditionOperator = ">=" // Greater Than or Equal To (>=) Operator LTEQ conditionOperator = "<=" // Less Than or Equal To (<=) Operator NGT conditionOperator = "!>" // Not Greater Than (!>) Operator NLT conditionOperator = "!<" // Not Less Than (!<) Operator IS conditionOperator = "is" // IS Operator ISNot conditionOperator = "is not" // IS NOT Operator )
View Source
const ( AND whereItemLinker = "and" // 1 = 1 and 2 = 2 OR whereItemLinker = "or" // 1 = 1 or 2 = 2 )
Variables ¶
View Source
var (
ErrorNilSQL = errors.New("nil SqlBuilder")
)
View Source
var ErrorNotConditionOperator = errors.New("not a condition operator")
Functions ¶
This section is empty.
Types ¶
type Condition ¶
type Condition struct { L Field `validate:"required"` O conditionOperator `validate:"required"` R interface{} `validate:"required"` }
condition
L field O condition operator R value
func (Condition) Condition ¶
func (c Condition) Condition(s *SqlBuilder) error
func (Condition) WhereItem ¶
func (c Condition) WhereItem(s *SqlBuilder) error
type Delete ¶
postgres https://www.postgresql.org/docs/current/sql-delete.html
func (Delete) ExecWithReturning ¶
type ExecWithReturning ¶
example: insert into table (field1) values (value1) returning field1
type Field ¶
type Field interface {
Field(*SqlBuilder, bool) error
}
Where field interface write field into SqlBuilder string builder example: field_1 or table_1.field
type Fields ¶
type Fields []Field
func (Fields) Fields ¶
func (fs Fields) Fields(s *SqlBuilder) error
type For ¶
type For string
const (
ForUpdate For = "update"
)
func (For) For ¶
func (f For) For(s *SqlBuilder) error
type Insert ¶
type Insert struct { Table `validate:"required"` Values map[Field]interface{} `validate:"required,dive,keys,required,endkeys,required"` Returning }
postgres https://www.postgresql.org/docs/current/sql-insert.html
func (Insert) ExecWithReturning ¶
type OrderBy ¶
type OrderBy map[Field]OrderByKind
type OrderByKind ¶
type OrderByKind string
const ( ASC OrderByKind = "asc" DESC OrderByKind = "desc" )
type Returning ¶
type Returning Fields
func (Returning) Returning ¶
func (r Returning) Returning(s *SqlBuilder) error
type Select ¶
type Select struct { FS Fields `validate:"required"` Table `validate:"required"` Where OrderBy Limit Offset For }
postgres https://www.postgresql.org/docs/current/sql-select.html
type SelectExists ¶
type SelectExists struct { FS Fields `validate:"required"` Table `validate:"required"` Where OrderBy Limit Offset For }
postgres https://www.postgresql.org/docs/current/sql-select.html
func (SelectExists) Fields ¶
func (slt SelectExists) Fields() Fields
func (SelectExists) Query ¶
func (slt SelectExists) Query() (string, []interface{}, error)
func (SelectExists) SQL ¶
func (slt SelectExists) SQL() (string, []interface{}, error)
type SqlBuilder ¶
type Table ¶
type Table interface {
Table(*SqlBuilder) error
}
Where table interface write table into SqlBuilder string builder example: table
type Update ¶
type Update struct { Table `validate:"required"` Set map[Field]interface{} `validate:"required"` Where Returning }
postgres https://www.postgresql.org/docs/current/sql-update.html
func (Update) ExecWithReturning ¶
type Where ¶
type Where WhereItems // `validate:"required,where_items_array_structure"`
type WhereItem ¶
type WhereItem interface {
WhereItem(*SqlBuilder) error
}
type WhereItems ¶
type WhereItems []WhereItem
func (WhereItems) WhereItem ¶
func (is WhereItems) WhereItem(s *SqlBuilder) error
func (WhereItems) WhereItems ¶
func (is WhereItems) WhereItems(s *SqlBuilder) error
Source Files ¶
- condition.go
- condtion_operator.go
- errors.go
- field1.go
- fields.go
- for.go
- function_count.go
- limit.go
- offset.go
- order_by.go
- public_interface.go
- returning.go
- sql_builder.go
- sql_delete.go
- sql_insert.go
- sql_select.go
- sql_select_exists.go
- sql_update.go
- validate.go
- validate_condtion_operator.go
- validate_where_items_array_structure.go
- where.go
- where_item_linker.go
- where_items.go
Click to show internal directories.
Click to hide internal directories.