Documentation ¶
Index ¶
- Variables
- func GetColParamSQL(p *Parses) (sql string)
- func GetColSQL(model any) (sql string)
- func GetColSQLAlias(model any, alias string) (sql string)
- func GetKeySQL(key string, model any, alias string) (sqlKey string, argsKey []any)
- func GetMoreColSQL(model any, tables ...string) (sql string)
- func GetMoreKeySQL(key string, model any, tables ...string) (sqlKey string, argsKey []any)
- func ParseTable(table string) string
- func StructWhereSQL(st any) (sql string, args []any)
- func TableOnly(table string) string
- func TagTables(tag string, tables ...string) (tbs []string)
- func UniqueTagTable(tag string, tables ...string) string
- type Config
- type Crud
- type CrudGo
- func (c *CrudGo) Begin() Crud
- func (c *CrudGo) Commit() Crud
- func (c *CrudGo) Count() Crud
- func (c *CrudGo) Create() Crud
- func (c *CrudGo) DB() *DB
- func (c *CrudGo) Delete(conds ...any) Crud
- func (c *CrudGo) Error() error
- func (c *CrudGo) Exec() Crud
- func (c *CrudGo) Find(p cmap.CMap) Crud
- func (c *CrudGo) FindM(params cmap.CMap) Crud
- func (c *CrudGo) FindS(params cmap.CMap) Crud
- func (c *CrudGo) From(query string) Crud
- func (c *CrudGo) Group(query string) Crud
- func (c *CrudGo) Init(param *Params)
- func (c *CrudGo) Pager() result.Pager
- func (c *CrudGo) Params(params ...Param) Crud
- func (c *CrudGo) Rollback() Crud
- func (c *CrudGo) RollbackTo(name string) Crud
- func (c *CrudGo) RowsAffected() int64
- func (c *CrudGo) SavePoint(name string) Crud
- func (c *CrudGo) Scan() Crud
- func (c *CrudGo) Select(q any, args ...any) Crud
- func (c *CrudGo) Update() Crud
- type DB
- func (db *DB) Create(table string, data any)
- func (db *DB) CreateMore(table string, model any, data any)
- func (db *DB) Delete(gt *GT, conds ...any)
- func (db *DB) Find(gt *GT) (pager result.Pager)
- func (db *DB) FindM(gt *GT) (pager result.Pager)
- func (db *DB) FindS(gt *GT) (pager result.Pager)
- func (db *DB) InitColumns(param *Params)
- func (db *DB) NewDB()
- func (db *DB) Update(gt *GT)
- type GT
- type Key
- type Param
- func Data(Data any) Param
- func Distinct(Distinct string) Param
- func Inner(InnerTables ...string) Param
- func KeyModel(KeyModel any) Param
- func Left(LeftTable ...string) Param
- func Model(Model any) Param
- func SubSQL(SubSQL ...string) Param
- func Table(Table string) Param
- func Valid(valid bool) Param
- func WhereSQL(WhereSQL string, args ...any) Param
- type Params
- type Parses
Constants ¶
This section is empty.
Variables ¶
var ( // TableCols table columns map TableCols = cmap.NewCMap() )
Functions ¶
func GetColSQLAlias ¶
GetColSQLAlias select * replace add alias
func GetMoreColSQL ¶
GetMoreColSQL select * replace select more tables : table name / table alias name first table must main table, like from a inner join b, first table is a
func GetMoreKeySQL ¶
GetMoreKeySQL more tables key search sql tables [table1:table1_alias] searModel : Model
func StructWhereSQL ¶
StructWhereSQL struct to where sql return key1 = value1 and key2 = value2...
func UniqueTagTable ¶
UniqueTagTable return unique tag table
Types ¶
type Crud ¶
type Crud interface { // Init init crud Init(*Params) // DB db DB() *DB // Params new/replace param // return param Params(...Param) Crud Count() Crud // count Find(cmap.CMap) Crud // find data FindM(cmap.CMap) Crud // find data more table no search // Delete delete by id/ids/slice Delete(...any) Crud // delete // Update crud and search id // json data Update() Crud // update Create() Crud // create (more), include res insert id Select(any, ...any) Crud // select sql From(string) Crud // from sql, if use search, From must only once Group(string) Crud // the last group by FindS(cmap.CMap) Crud // Select origin sql find, params only support Pager and Mock Scan() Crud // no search Exec() Crud // exec insert/update/delete sql Error() error // crud error RowsAffected() int64 // inflect rows Pager() result.Pager // search pager Begin() Crud // start a transaction Commit() Crud // commit a transaction Rollback() Crud // rollback a transaction SavePoint(string) Crud // save a point RollbackTo(string) Crud // rollback to point }
Crud interface
type CrudGo ¶ added in v1.2.3
type CrudGo struct {
// contains filtered or unexported fields
}
CrudGo implement Crud
func (*CrudGo) RollbackTo ¶ added in v1.2.3
func (*CrudGo) RowsAffected ¶ added in v1.2.3
type DB ¶
DB tool
func (*DB) CreateMore ¶
CreateMore data must array type more data create single table also can use Create array
func (*DB) FindM ¶
FindM no search params: innerTables is inner join tables params: leftTables is left join tables return search info table1 as main table, include other tables_id(foreign key)
func (*DB) InitColumns ¶
InitColumns init db table columns map
type GT ¶
type GT struct { *Params // CMap CMaps cmap.CMap // params Select string // select sql From string // only once Group string // the last group Args []any // contains filtered or unexported fields }
GT SQL struct
func (*GT) GetMoreSQL ¶
func (gt *GT) GetMoreSQL()
GetMoreSQL more table params: innerTables is inner join tables, must even number params: leftTables is left join tables return: select sql table1 as main table, include other tables_id(foreign key)
type Params ¶
type Params struct { // attributes InnerTable []string // inner join tables LeftTable []string // left join tables Table string // table name Model any // table model, like User{} KeyModel any // key like model Data any // table model data, like var user User{}, it is 'user', it store real data // sub query SubSQL string // SubQuery SQL // where WhereSQL string // Where SQL // contains filtered or unexported fields }
Params crud params