Documentation ¶
Index ¶
- func All[T any](cb *CmdBuilder) (ret []*T)
- func DeleteByModel(d *Orm, model TableNameProvider) int64
- func DeleteWhere(d *Orm, model TableNameProvider, clause any, args ...any) int64
- func InsertModelGetId(d *Orm, model TableNameProvider) int64
- func One[T any](cb *CmdBuilder) (ret T)
- func OneByModel[T TableNameProvider](d *Orm, model T) (_ T)
- func OneWhere[T TableNameProvider](d *Orm, clause any, args ...any) (ret T)
- func UpdateModelByModel(d *Orm, model TableNameProvider, where TableNameProvider) int64
- func UpdateModelWhere(d *Orm, model TableNameProvider, clause any, args ...any) int64
- type And
- type ClauseProvider
- type CmdBuilder
- func (cb *CmdBuilder) Columns(cols ...string) *CmdBuilder
- func (cb *CmdBuilder) Delete() (sql.Result, error)
- func (cb *CmdBuilder) GroupBy(groupBy string) *CmdBuilder
- func (cb *CmdBuilder) Having(clause any, args ...any) *CmdBuilder
- func (cb *CmdBuilder) InsertFull(row any) (sql.Result, error)
- func (cb *CmdBuilder) InsertModel(row any) (sql.Result, error)
- func (cb *CmdBuilder) InsertRow(row any) (sql.Result, error)
- func (cb *CmdBuilder) Limit(n ...int) *CmdBuilder
- func (cb *CmdBuilder) OrderBy(orderBy string) *CmdBuilder
- func (cb *CmdBuilder) SelectAll(rowsPtr any) error
- func (cb *CmdBuilder) SelectOne(result any) (found bool, err error)
- func (cb *CmdBuilder) Table(v any) *CmdBuilder
- func (cb *CmdBuilder) UpdateFull(row any) (sql.Result, error)
- func (cb *CmdBuilder) UpdateModel(row any) (sql.Result, error)
- func (cb *CmdBuilder) UpdateRow(row any) (sql.Result, error)
- func (cb *CmdBuilder) Where(clause any, args ...any) *CmdBuilder
- func (cb *CmdBuilder) WhereModel(model TableNameProvider) *CmdBuilder
- type CondMap
- type DbExecutor
- type Dialect
- type DialectMySQL
- type DialectNop
- type ModelStructField
- type ModelStructFields
- type NotAnd
- type NotOr
- type Or
- type Orm
- func (d *Orm) Cmd() *CmdBuilder
- func (d *Orm) Columns(cols ...string) *CmdBuilder
- func (d *Orm) Exec(query string, args ...any) (sql.Result, error)
- func (d *Orm) Get(dest any, query string, args ...any) error
- func (d *Orm) Select(dest any, query string, args ...any) error
- func (d *Orm) Table(t any) *CmdBuilder
- func (d *Orm) Where(clause any, args ...any) *CmdBuilder
- func (d *Orm) WhereModel(model TableNameProvider) *CmdBuilder
- type SqlCmd
- type TableNameProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
func All[T any](cb *CmdBuilder) (ret []*T)
func DeleteByModel ¶
func DeleteByModel(d *Orm, model TableNameProvider) int64
func DeleteWhere ¶
func DeleteWhere(d *Orm, model TableNameProvider, clause any, args ...any) int64
func InsertModelGetId ¶
func InsertModelGetId(d *Orm, model TableNameProvider) int64
func One ¶
func One[T any](cb *CmdBuilder) (ret T)
func OneByModel ¶
func OneByModel[T TableNameProvider](d *Orm, model T) (_ T)
func UpdateModelByModel ¶
func UpdateModelByModel(d *Orm, model TableNameProvider, where TableNameProvider) int64
func UpdateModelWhere ¶
func UpdateModelWhere(d *Orm, model TableNameProvider, clause any, args ...any) int64
Types ¶
type ClauseProvider ¶
type CmdBuilder ¶
type CmdBuilder struct {
// contains filtered or unexported fields
}
func NewCmdBuilder ¶
func NewCmdBuilder(orm *Orm) *CmdBuilder
func (*CmdBuilder) Columns ¶
func (cb *CmdBuilder) Columns(cols ...string) *CmdBuilder
Columns is only for UPDATE/INSERT
func (*CmdBuilder) GroupBy ¶
func (cb *CmdBuilder) GroupBy(groupBy string) *CmdBuilder
func (*CmdBuilder) Having ¶
func (cb *CmdBuilder) Having(clause any, args ...any) *CmdBuilder
func (*CmdBuilder) InsertFull ¶
func (cb *CmdBuilder) InsertFull(row any) (sql.Result, error)
func (*CmdBuilder) InsertModel ¶
func (cb *CmdBuilder) InsertModel(row any) (sql.Result, error)
func (*CmdBuilder) Limit ¶
func (cb *CmdBuilder) Limit(n ...int) *CmdBuilder
Limit demo SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15
func (*CmdBuilder) OrderBy ¶
func (cb *CmdBuilder) OrderBy(orderBy string) *CmdBuilder
func (*CmdBuilder) SelectAll ¶
func (cb *CmdBuilder) SelectAll(rowsPtr any) error
func (*CmdBuilder) Table ¶
func (cb *CmdBuilder) Table(v any) *CmdBuilder
func (*CmdBuilder) UpdateFull ¶
func (cb *CmdBuilder) UpdateFull(row any) (sql.Result, error)
func (*CmdBuilder) UpdateModel ¶
func (cb *CmdBuilder) UpdateModel(row any) (sql.Result, error)
func (*CmdBuilder) Where ¶
func (cb *CmdBuilder) Where(clause any, args ...any) *CmdBuilder
func (*CmdBuilder) WhereModel ¶
func (cb *CmdBuilder) WhereModel(model TableNameProvider) *CmdBuilder
type DbExecutor ¶
type DialectMySQL ¶
type DialectMySQL struct { }
func (*DialectMySQL) NameQuoter ¶
func (d *DialectMySQL) NameQuoter() (string, string)
func (*DialectMySQL) QuoteName ¶
func (d *DialectMySQL) QuoteName(s string) string
type DialectNop ¶
type DialectNop struct { }
func (*DialectNop) NameQuoter ¶
func (d *DialectNop) NameQuoter() (string, string)
func (*DialectNop) QuoteName ¶
func (d *DialectNop) QuoteName(s string) string
type ModelStructField ¶
type ModelStructFields ¶
type ModelStructFields []*ModelStructField
type Orm ¶
type Orm struct {
// contains filtered or unexported fields
}
func (*Orm) Cmd ¶
func (d *Orm) Cmd() *CmdBuilder
func (*Orm) Columns ¶
func (d *Orm) Columns(cols ...string) *CmdBuilder
func (*Orm) Table ¶
func (d *Orm) Table(t any) *CmdBuilder
func (*Orm) WhereModel ¶
func (d *Orm) WhereModel(model TableNameProvider) *CmdBuilder
type SqlCmd ¶
func (*SqlCmd) AppendClause ¶
func (sc *SqlCmd) AppendClause(orm *Orm, c ClauseProvider) error
type TableNameProvider ¶
type TableNameProvider interface {
TableName() string
}
Click to show internal directories.
Click to hide internal directories.