Documentation
¶
Index ¶
- Constants
- Variables
- func CreatePointerAndSlice(input interface{}) (interface{}, interface{})
- func DeepCopy(src any) (any, error)
- func EachOR(conds any) any
- func NewController(conn any, op Operator, m any) func(ctx context.Context) Controller
- func StrSlice2Map(s []string) (res map[string]struct{})
- func Struct2Map(obj any, tag string) map[string]any
- func StructSlice2MapSlice(obj any, tag string) []map[string]any
- func ToOR(key string) string
- type AND
- type Cond
- type Controller
- type Impl
- func (m *Impl) BulkInsert(data []map[string]any, handler sqlx.ResultHandler) (err error)
- func (m *Impl) BulkInsertModel(modelSlice any, handler sqlx.ResultHandler) (err error)
- func (m *Impl) Count() (num int64, err error)
- func (m *Impl) CreateIfNotExist(data map[string]any) (id int64, created bool, err error)
- func (m *Impl) CreateOrUpdate(data map[string]any, filter ...any) (bool, int64, error)
- func (m *Impl) Delete() (int64, error)
- func (m *Impl) Exclude(exclude ...any) Controller
- func (m *Impl) Exist() (exist bool, err error)
- func (m *Impl) Filter(filter ...any) Controller
- func (m *Impl) FindAll() (result []map[string]any, err error)
- func (m *Impl) FindAllModel(modelSlicePtr any) (err error)
- func (m *Impl) FindOne() (result map[string]any, err error)
- func (m *Impl) FindOneModel(modelPtr any) (err error)
- func (m *Impl) GetC2CMap(column1, column2 string) (res map[any]any, err error)
- func (m *Impl) GetOrCreate(data map[string]any) (map[string]any, error)
- func (m *Impl) GroupBy(groupBy any) Controller
- func (m *Impl) Having(having string, args ...any) Controller
- func (m *Impl) Insert(data map[string]any) (id int64, err error)
- func (m *Impl) InsertModel(model any) (id int64, err error)
- func (m *Impl) Limit(pageSize, pageNum int64) Controller
- func (m *Impl) List() (total int64, data []map[string]any, err error)
- func (m *Impl) Modify(data map[string]any) (num int64, err error)
- func (m *Impl) OrderBy(orderBy any) Controller
- func (m *Impl) Remove() (num int64, err error)
- func (m *Impl) Reset() Controller
- func (m *Impl) Select(selects any) Controller
- func (m *Impl) Update(data map[string]any) (num int64, err error)
- func (m *Impl) Where(cond string, args ...any) Controller
- func (m *Impl) WithSession(session sqlx.Session) Controller
- type OR
- type Operator
- type QuerySet
- type QuerySetImpl
- func (p *QuerySetImpl) Error() error
- func (p *QuerySetImpl) FilterToSQL(isNot int, filter ...any) QuerySet
- func (p *QuerySetImpl) GetGroupBySQL() string
- func (p *QuerySetImpl) GetHavingSQL() (string, []any)
- func (p *QuerySetImpl) GetLimitSQL() string
- func (p *QuerySetImpl) GetOrderBySQL() string
- func (p *QuerySetImpl) GetQuerySet() (sql string, args []any)
- func (p *QuerySetImpl) GetSelectSQL() string
- func (p *QuerySetImpl) GroupByToSQL(groupBy any) QuerySet
- func (p *QuerySetImpl) HavingToSQL(having string, args ...any) QuerySet
- func (p *QuerySetImpl) LimitToSQL(pageSize, pageNum int64) QuerySet
- func (p *QuerySetImpl) OrderByToSQL(orderBy any) QuerySet
- func (p *QuerySetImpl) Reset()
- func (p *QuerySetImpl) SelectToSQL(columns any) QuerySet
- func (p *QuerySetImpl) SliceGroupByToSQL(groupBy []string) QuerySet
- func (p *QuerySetImpl) SliceOrderByToSQL(orderBy []string) QuerySet
- func (p *QuerySetImpl) SliceSelectToSQL(columns []string) QuerySet
- func (p *QuerySetImpl) StrGroupByToSQL(groupBy string) QuerySet
- func (p *QuerySetImpl) StrOrderByToSQL(orderBy string) QuerySet
- func (p *QuerySetImpl) StrSelectToSQL(columns string) QuerySet
- func (p *QuerySetImpl) WhereToSQL(cond string, args ...any) QuerySet
Constants ¶
View Source
const ( DefaultModelTag = "db" SelectTemp = "SELECT %s FROM %s" InsertTemp = "INSERT INTO %s (%s) VALUES (%s)" UpdateTemp = "UPDATE %s SET %s" DeleteTemp = "DELETE FROM %s" )
View Source
const (
SortKey = "~sort~"
)
View Source
const (
UnsupportedControllerError = "%s not supported for %s"
)
Variables ¶
View Source
var ( ErrDuplicateKey = operator.ErrDuplicateKey ErrNotFound = operator.ErrNotFound )
Functions ¶
func CreatePointerAndSlice ¶
func CreatePointerAndSlice(input interface{}) (interface{}, interface{})
func NewController ¶
func StrSlice2Map ¶
StrSlice2Map convert string slice to map
func Struct2Map ¶
Struct2Map convert struct to map, tag is the tag name of struct
func StructSlice2MapSlice ¶
StructSlice2MapSlice convert struct slice to map slice, tag is the tag name of struct
Types ¶
type Controller ¶
type Controller interface { WithSession(session sqlx.Session) Controller Reset() Controller Filter(filter ...any) Controller Exclude(exclude ...any) Controller Where(cond string, args ...any) Controller Select(columns any) Controller Limit(pageSize, pageNum int64) Controller OrderBy(orderBy any) Controller GroupBy(groupBy any) Controller Having(having string, args ...any) Controller Insert(data map[string]any) (id int64, err error) InsertModel(model any) (id int64, err error) //BulkInsert(data []map[string]any, handler sqlx.ResultHandler) (err error) //BulkInsertModel(modelSlice any, handler sqlx.ResultHandler) (err error) Remove() (num int64, err error) Update(data map[string]any) (num int64, err error) Count() (num int64, err error) FindOne() (result map[string]any, err error) FindOneModel(modelPtr any) (err error) FindAll() (result []map[string]any, err error) FindAllModel(modelSlicePtr any) (err error) Delete() (num int64, err error) Modify(data map[string]any) (num int64, err error) Exist() (exist bool, error error) List() (num int64, data []map[string]any, err error) GetOrCreate(data map[string]any) (result map[string]any, err error) CreateOrUpdate(data map[string]any, filter ...any) (created bool, num int64, err error) GetC2CMap(column1, column2 string) (res map[any]any, err error) CreateIfNotExist(data map[string]any) (id int64, created bool, err error) // contains filtered or unexported methods }
type Impl ¶
type Impl struct {
// contains filtered or unexported fields
}
func (*Impl) BulkInsert ¶
func (*Impl) BulkInsertModel ¶
func (m *Impl) BulkInsertModel(modelSlice any, handler sqlx.ResultHandler) (err error)
func (*Impl) CreateIfNotExist ¶
func (*Impl) CreateOrUpdate ¶
func (*Impl) Exclude ¶
func (m *Impl) Exclude(exclude ...any) Controller
func (*Impl) Filter ¶
func (m *Impl) Filter(filter ...any) Controller
func (*Impl) FindAllModel ¶
func (*Impl) FindOneModel ¶
func (*Impl) GroupBy ¶
func (m *Impl) GroupBy(groupBy any) Controller
func (*Impl) Limit ¶
func (m *Impl) Limit(pageSize, pageNum int64) Controller
func (*Impl) OrderBy ¶
func (m *Impl) OrderBy(orderBy any) Controller
func (*Impl) Reset ¶
func (m *Impl) Reset() Controller
func (*Impl) Select ¶
func (m *Impl) Select(selects any) Controller
func (*Impl) WithSession ¶
func (m *Impl) WithSession(session sqlx.Session) Controller
type QuerySet ¶
type QuerySet interface { Error() error Reset() GetQuerySet() (string, []any) FilterToSQL(notTag int, filter ...any) QuerySet WhereToSQL(cond string, args ...any) QuerySet GetSelectSQL() string SelectToSQL(columns any) QuerySet StrSelectToSQL(columns string) QuerySet SliceSelectToSQL(columns []string) QuerySet GetLimitSQL() string LimitToSQL(pageSize, pageNum int64) QuerySet GetOrderBySQL() string OrderByToSQL(orderBy any) QuerySet StrOrderByToSQL(orderBy string) QuerySet SliceOrderByToSQL(orderBy []string) QuerySet GetGroupBySQL() string GroupByToSQL(groupBy any) QuerySet StrGroupByToSQL(groupBy string) QuerySet SliceGroupByToSQL(groupBy []string) QuerySet GetHavingSQL() (string, []any) HavingToSQL(having string, args ...any) QuerySet // contains filtered or unexported methods }
func NewQuerySet ¶
type QuerySetImpl ¶
type QuerySetImpl struct { Operator // contains filtered or unexported fields }
func (*QuerySetImpl) Error ¶
func (p *QuerySetImpl) Error() error
func (*QuerySetImpl) FilterToSQL ¶
func (p *QuerySetImpl) FilterToSQL(isNot int, filter ...any) QuerySet
func (*QuerySetImpl) GetGroupBySQL ¶
func (p *QuerySetImpl) GetGroupBySQL() string
func (*QuerySetImpl) GetHavingSQL ¶ added in v0.0.3
func (p *QuerySetImpl) GetHavingSQL() (string, []any)
func (*QuerySetImpl) GetLimitSQL ¶
func (p *QuerySetImpl) GetLimitSQL() string
func (*QuerySetImpl) GetOrderBySQL ¶
func (p *QuerySetImpl) GetOrderBySQL() string
func (*QuerySetImpl) GetQuerySet ¶
func (p *QuerySetImpl) GetQuerySet() (sql string, args []any)
func (*QuerySetImpl) GetSelectSQL ¶
func (p *QuerySetImpl) GetSelectSQL() string
func (*QuerySetImpl) GroupByToSQL ¶
func (p *QuerySetImpl) GroupByToSQL(groupBy any) QuerySet
func (*QuerySetImpl) HavingToSQL ¶ added in v0.0.3
func (p *QuerySetImpl) HavingToSQL(having string, args ...any) QuerySet
func (*QuerySetImpl) LimitToSQL ¶
func (p *QuerySetImpl) LimitToSQL(pageSize, pageNum int64) QuerySet
func (*QuerySetImpl) OrderByToSQL ¶
func (p *QuerySetImpl) OrderByToSQL(orderBy any) QuerySet
func (*QuerySetImpl) Reset ¶
func (p *QuerySetImpl) Reset()
func (*QuerySetImpl) SelectToSQL ¶
func (p *QuerySetImpl) SelectToSQL(columns any) QuerySet
func (*QuerySetImpl) SliceGroupByToSQL ¶ added in v0.0.2
func (p *QuerySetImpl) SliceGroupByToSQL(groupBy []string) QuerySet
func (*QuerySetImpl) SliceOrderByToSQL ¶ added in v0.0.2
func (p *QuerySetImpl) SliceOrderByToSQL(orderBy []string) QuerySet
func (*QuerySetImpl) SliceSelectToSQL ¶ added in v0.0.2
func (p *QuerySetImpl) SliceSelectToSQL(columns []string) QuerySet
func (*QuerySetImpl) StrGroupByToSQL ¶ added in v0.0.2
func (p *QuerySetImpl) StrGroupByToSQL(groupBy string) QuerySet
func (*QuerySetImpl) StrOrderByToSQL ¶ added in v0.0.2
func (p *QuerySetImpl) StrOrderByToSQL(orderBy string) QuerySet
func (*QuerySetImpl) StrSelectToSQL ¶ added in v0.0.2
func (p *QuerySetImpl) StrSelectToSQL(columns string) QuerySet
func (*QuerySetImpl) WhereToSQL ¶
func (p *QuerySetImpl) WhereToSQL(cond string, args ...any) QuerySet
Click to show internal directories.
Click to hide internal directories.