Documentation
¶
Index ¶
- Variables
- func CreateStructFromTable(table Table) error
- func CreateTableFromStruct(table Table) (string, error)
- func SetDefaults(table Table)
- func SliceContain(array interface{}, val interface{}) (index int)
- type JoinType
- type JsonInt
- type JsonTime
- type Query
- func (m *Query) AliasTable(alias string) *Query
- func (m *Query) DB() *sql.DB
- func (m *Query) Delete() QueryResult
- func (m *Query) ExecuteRaw(prepareSql string, bindings ...interface{}) QueryResult
- func (m *Query) FromTable(table Table, alias ...string) *Query
- func (m *Query) GroupBy(columns ...interface{}) *Query
- func (m *Query) Having(where func(*Query)) *Query
- func (m *Query) Insert(data interface{}, tableFieldAddrs ...interface{}) QueryResult
- func (m *Query) InsertIgnore(data interface{}, tableFieldAddrs []interface{}, updates ...UpdateColumn) QueryResult
- func (m *Query) Join(table Table, where func(join *Query), alias ...string) *Query
- func (m *Query) LeftJoin(table Table, where func(join *Query), alias ...string) *Query
- func (m *Query) Limit(limit int) *Query
- func (m *Query) Offset(offset int) *Query
- func (m *Query) OrWhere(column interface{}, vals ...interface{}) *Query
- func (m *Query) OrWhereGroup(f func(*Query)) *Query
- func (m *Query) OrderBy(column interface{}) *Query
- func (m *Query) OrderByDesc(column interface{}) *Query
- func (m *Query) RightJoin(table Table, where func(join *Query), alias ...string) *Query
- func (m *Query) Select(dest interface{}, columns ...interface{}) QueryResult
- func (m *Query) SelectCount(dest interface{}) QueryResult
- func (m *Query) SelectForUpdate(dest interface{}, columns ...interface{}) QueryResult
- func (m *Query) SelectMapOfColumn2KeyByColumn1(dest interface{}, columns ...interface{}) QueryResult
- func (m *Query) SelectMapOfStructKeyByColumn1(dest interface{}, columns ...interface{}) QueryResult
- func (m *Query) SelectMapOfStructSliceKeyByColumn1(dest interface{}, columns ...interface{}) QueryResult
- func (m *Query) SelectMapStr2Interface(dest *map[string]interface{}, columns ...interface{}) QueryResult
- func (m *Query) SelectRaw(dest interface{}, prepareSql string, bindings ...interface{}) QueryResult
- func (m *Query) SelectSliceOfColumn1(dest interface{}, columns ...interface{}) QueryResult
- func (m *Query) SelectSliceOfMapStr2Interface(dest *[]map[string]interface{}, columns ...interface{}) QueryResult
- func (m *Query) SelectSliceOfStruct(dest interface{}, columns ...interface{}) QueryResult
- func (m *Query) SelectStructOfRow1(dest interface{}, columns ...interface{}) QueryResult
- func (m *Query) SelectSub(columns ...interface{}) *tempTable
- func (m *Query) SelectValueOfFirstCell(dest interface{}, columns ...interface{}) QueryResult
- func (m *Query) Transaction(query func(db *Query) error) error
- func (m *Query) Update(column interface{}, val interface{}) QueryResult
- func (m *Query) Updates(updates ...UpdateColumn) QueryResult
- func (m *Query) UseDB(db *sql.DB) *Query
- func (m *Query) UseTx(tx *sql.Tx) *Query
- func (m *Query) Where(column interface{}, vals ...interface{}) *Query
- func (m *Query) WhereGroup(f func(*Query)) *Query
- type QueryResult
- type Raw
- type Table
- type UpdateColumn
- type WhereOperator
Constants ¶
This section is empty.
Variables ¶
View Source
var AllCols = "*"
Functions ¶
func CreateStructFromTable ¶ added in v0.2.0
func CreateTableFromStruct ¶ added in v0.2.0
func SetDefaults ¶ added in v0.2.1
func SetDefaults(table Table)
func SliceContain ¶
func SliceContain(array interface{}, val interface{}) (index int)
Types ¶
type JsonTime ¶
func (JsonTime) MarshalJSON ¶
MarshalJSON on JsonTime format Time field with %Y-%m-%d %H:%M:%S
func (*JsonTime) UnmarshalJSON ¶
MarshalJSON on JsonTime format Time field with %Y-%m-%d %H:%M:%S
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
func (*Query) AliasTable ¶
func (*Query) Delete ¶
func (m *Query) Delete() QueryResult
func (*Query) ExecuteRaw ¶ added in v0.2.0
func (m *Query) ExecuteRaw(prepareSql string, bindings ...interface{}) QueryResult
func (*Query) Insert ¶
func (m *Query) Insert(data interface{}, tableFieldAddrs ...interface{}) QueryResult
tableFieldAddrs: allow insert table columns
func (*Query) InsertIgnore ¶
func (m *Query) InsertIgnore(data interface{}, tableFieldAddrs []interface{}, updates ...UpdateColumn) QueryResult
insert ignore ... // on duplicate key update ...
func (*Query) OrWhereGroup ¶
"id=1" &obj.id, 1 &obj.id, "=", 1
func (*Query) OrderByDesc ¶
func (*Query) Select ¶
func (m *Query) Select(dest interface{}, columns ...interface{}) QueryResult
func (*Query) SelectCount ¶
func (m *Query) SelectCount(dest interface{}) QueryResult
dest: *int | *int64 | ...
func (*Query) SelectForUpdate ¶
func (m *Query) SelectForUpdate(dest interface{}, columns ...interface{}) QueryResult
func (*Query) SelectMapOfColumn2KeyByColumn1 ¶
func (m *Query) SelectMapOfColumn2KeyByColumn1(dest interface{}, columns ...interface{}) QueryResult
dest: *map [int | string | ...] int | string ...
func (*Query) SelectMapOfStructKeyByColumn1 ¶
func (m *Query) SelectMapOfStructKeyByColumn1(dest interface{}, columns ...interface{}) QueryResult
dest: *map [int | string | ...] struct
func (*Query) SelectMapOfStructSliceKeyByColumn1 ¶
func (m *Query) SelectMapOfStructSliceKeyByColumn1(dest interface{}, columns ...interface{}) QueryResult
dest: *map [int | string | ...] []struct
func (*Query) SelectMapStr2Interface ¶ added in v0.2.0
func (m *Query) SelectMapStr2Interface(dest *map[string]interface{}, columns ...interface{}) QueryResult
dest, first of sql rows: *map[column_name]column_value
func (*Query) SelectRaw ¶ added in v0.2.0
func (m *Query) SelectRaw(dest interface{}, prepareSql string, bindings ...interface{}) QueryResult
select from raw sql
func (*Query) SelectSliceOfColumn1 ¶
func (m *Query) SelectSliceOfColumn1(dest interface{}, columns ...interface{}) QueryResult
dest: *[]int | *[]string | ...
func (*Query) SelectSliceOfMapStr2Interface ¶ added in v0.2.0
func (m *Query) SelectSliceOfMapStr2Interface(dest *[]map[string]interface{}, columns ...interface{}) QueryResult
dest, sql rows: *[]map[column_name]column_value
func (*Query) SelectSliceOfStruct ¶
func (m *Query) SelectSliceOfStruct(dest interface{}, columns ...interface{}) QueryResult
dest: *[]struct
func (*Query) SelectStructOfRow1 ¶
func (m *Query) SelectStructOfRow1(dest interface{}, columns ...interface{}) QueryResult
dest: *struct
func (*Query) SelectValueOfFirstCell ¶
func (m *Query) SelectValueOfFirstCell(dest interface{}, columns ...interface{}) QueryResult
dest: *int | *string | ...
func (*Query) Update ¶
func (m *Query) Update(column interface{}, val interface{}) QueryResult
func (*Query) Updates ¶
func (m *Query) Updates(updates ...UpdateColumn) QueryResult
func (*Query) WhereGroup ¶
"id=1" &obj.id, 1 &obj.id, "=", 1
type QueryResult ¶
type QueryResult struct {
PrepareSql string
Bindings []interface{}
LastInsertId int64
RowsAffected int64
Err error
}
func (*QueryResult) Sql ¶
func (q *QueryResult) Sql() string
type UpdateColumn ¶
type UpdateColumn struct {
Column interface{}
Val interface{}
}
type WhereOperator ¶
type WhereOperator Raw
const ( WhereEqual WhereOperator = "=" WhereNotEqual WhereOperator = "!=" WhereGreatThan WhereOperator = ">" WhereGreaterOrEqual WhereOperator = ">=" WhereLessThan WhereOperator = "<" WhereLessOrEqual WhereOperator = "<=" WhereIn WhereOperator = "in" WhereNotIn WhereOperator = "not in" WhereLike WhereOperator = "like" WhereNotLike WhereOperator = "not like" WhereRlike WhereOperator = "rlike" WhereNotRlike WhereOperator = "not rlike" WhereIsNull WhereOperator = "is null" WhereIsNotNull WhereOperator = "is not null" )
Source Files
¶
- create_struct_from_table.go
- create_table_from_struct.go
- fill_default.go
- json_fields.go
- json_int.go
- json_slice.go
- json_time.go
- query.go
- query_delete.go
- query_execute.go
- query_insert.go
- query_join.go
- query_result.go
- query_select.go
- query_table.go
- query_table_cache.go
- query_transaction.go
- query_update.go
- query_where.go
- table.go
- temp_table.go
- update_column.go
- where.go
Click to show internal directories.
Click to hide internal directories.