Documentation
¶
Index ¶
- func CreateStructFromTable[T Table](queryTable Query[T]) error
- func CreateTableFromStruct[T Table](query Query[T]) (string, error)
- func ErrorNotNil(errors ...error) error
- func SetDefaults(table Table)
- func SliceContain(array interface{}, val interface{}) (index int)
- type JoinType
- type JsonInt
- type JsonTime
- type Query
- func (m Query[T]) Alias(alias string) Query[T]
- func (m Query[T]) AllCols() string
- func (m Query[T]) DB() *sql.DB
- func (m Query[T]) Delete() QueryResult
- func (m Query[T]) Execute() QueryResult
- func (m Query[T]) FromTable(table Table, alias ...string) Query[T]
- func (m Query[T]) Get() (T, QueryResult)
- func (m Query[T]) GetCount() (int64, QueryResult)
- func (m Query[T]) GetRow() (map[string]interface{}, QueryResult)
- func (m Query[T]) GetRows() ([]map[string]interface{}, QueryResult)
- func (m Query[T]) GetTo(destPtr interface{}) QueryResult
- func (m Query[T]) Gets() ([]T, QueryResult)
- func (m Query[T]) GroupBy(columns ...interface{}) Query[T]
- func (m Query[T]) Having(column interface{}, vals ...interface{}) Query[T]
- func (m Query[T]) Insert(data T, tableFieldAddrs ...interface{}) QueryResult
- func (m Query[T]) InsertSubquery(data *SubQuery, tableFieldPtrs []interface{}, updates ...UpdateColumn) QueryResult
- func (m Query[T]) Inserts(data []T, tableFieldAddrs ...interface{}) QueryResult
- func (m Query[T]) InsertsIgnore(data []T, tableFieldPtrs []interface{}, updates ...UpdateColumn) QueryResult
- func (m Query[T]) Join(table Table, where func(join Query[T]) Query[T], alias ...string) Query[T]
- func (m Query[T]) LeftJoin(table Table, where func(join Query[T]) Query[T], alias ...string) Query[T]
- func (m Query[T]) Limit(limit int) Query[T]
- func (m Query[T]) Offset(offset int) Query[T]
- func (m Query[T]) OrWhere(column interface{}, vals ...interface{}) Query[T]
- func (m Query[T]) OrWhereFunc(f func(Query[T]) Query[T]) Query[T]
- func (m Query[T]) OrderBy(column interface{}) Query[T]
- func (m Query[T]) OrderByDesc(column interface{}) Query[T]
- func (m Query[T]) Raw(prepareSql string, bindings ...interface{}) Query[T]
- func (m Query[T]) RightJoin(table Table, where func(join Query[T]) Query[T], alias ...string) Query[T]
- func (m Query[T]) Select(columns ...interface{}) Query[T]
- func (m Query[T]) SelectForUpdate(columns ...interface{}) Query[T]
- func (m Query[T]) SubQuery() *SubQuery
- func (m Query[T]) TableInterface() Table
- func (m Query[T]) Transaction(q func(tx *sql.Tx) error) error
- func (m Query[T]) Update(column interface{}, val interface{}) QueryResult
- func (m Query[T]) Updates(updates ...UpdateColumn) QueryResult
- func (m Query[T]) UseDB(db *sql.DB) Query[T]
- func (m Query[T]) UseTx(tx *sql.Tx) Query[T]
- func (m Query[T]) Where(column interface{}, vals ...interface{}) Query[T]
- func (m Query[T]) WhereFunc(f func(Query[T]) Query[T]) Query[T]
- type QueryResult
- type Raw
- type SubQuery
- type Table
- type UpdateColumn
- type WhereOperator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateStructFromTable ¶ added in v0.2.0
func CreateTableFromStruct ¶ added in v0.2.0
func ErrorNotNil ¶ added in v0.3.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[T Table] struct { T *T // contains filtered or unexported fields }
func (Query[T]) Delete ¶
func (m Query[T]) Delete() QueryResult
func (Query[T]) GetCount ¶ added in v0.3.0
func (m Query[T]) GetCount() (int64, QueryResult)
get count T
func (Query[T]) GetRow ¶ added in v0.3.0
func (m Query[T]) GetRow() (map[string]interface{}, QueryResult)
get first row
func (Query[T]) GetRows ¶ added in v0.3.0
func (m Query[T]) GetRows() ([]map[string]interface{}, QueryResult)
get slice row
func (Query[T]) GetTo ¶ added in v0.3.0
func (m Query[T]) GetTo(destPtr interface{}) QueryResult
destPtr: *int | *int64 | *string | ... destPtr: *[]int | *[]string | ... destPtr: *struct | *[]struct destPtr: *map [int | string | ...] int | string ... destPtr: *map [int | string | ...] struct destPtr: *map [int | string | ...] []struct
func (Query[T]) Insert ¶
func (m Query[T]) Insert(data T, tableFieldAddrs ...interface{}) QueryResult
tableFieldAddrs: allow insert table columns
func (Query[T]) InsertSubquery ¶ added in v0.3.0
func (m Query[T]) InsertSubquery(data *SubQuery, tableFieldPtrs []interface{}, updates ...UpdateColumn) QueryResult
func (Query[T]) Inserts ¶ added in v0.3.0
func (m Query[T]) Inserts(data []T, tableFieldAddrs ...interface{}) QueryResult
tableFieldAddrs: allow insert table columns
func (Query[T]) InsertsIgnore ¶ added in v0.3.0
func (m Query[T]) InsertsIgnore(data []T, tableFieldPtrs []interface{}, updates ...UpdateColumn) QueryResult
insert ignore ... // on duplicate key update ...
func (Query[T]) OrWhereFunc ¶ added in v0.3.0
"id=1" &obj.id, 1 &obj.id, "=", 1
func (Query[T]) OrderByDesc ¶
func (Query[T]) SelectForUpdate ¶
func (Query[T]) TableInterface ¶ added in v0.3.0
func (Query[T]) Update ¶
func (m Query[T]) Update(column interface{}, val interface{}) QueryResult
func (Query[T]) Updates ¶
func (m Query[T]) Updates(updates ...UpdateColumn) QueryResult
type QueryResult ¶
type QueryResult struct {
PrepareSql string
Bindings []interface{}
LastInsertId int64
RowsAffected int64
Err error
}
func (QueryResult) Error ¶ added in v0.3.0
func (q QueryResult) Error() error
func (QueryResult) Sql ¶
func (q QueryResult) Sql() string
type SubQuery ¶ added in v0.3.0
type SubQuery struct {
// contains filtered or unexported fields
}
func (SubQuery) DatabaseName ¶ added in v0.3.0
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
- err.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_get.go
- query_insert.go
- query_join.go
- query_raw.go
- query_result.go
- query_select.go
- query_sub.go
- query_table.go
- query_table_cache.go
- query_transaction.go
- query_update.go
- query_where.go
- string.go
- table.go
- temp_table.go
- update_column.go
- where.go
Click to show internal directories.
Click to hide internal directories.