Documentation ¶
Index ¶
- Constants
- Variables
- func EnableDebug(b bool)
- func GetStructFieldNames(i interface{}) []string
- func RegisterDefaultDialect(name string, dialect Dialect)
- func RegisterDialect(name string, dialect Dialect)
- func SetDefaultDialect(name string) bool
- func SetLogger(l Logger)
- type Action
- type Builder
- func (b *Builder) Apply(options ...BuilderOptionFunc) *Builder
- func (b *Builder) Build() Template
- func (b *Builder) Delete(table string) *Builder
- func (b *Builder) Dialect(d string) *Builder
- func (b *Builder) Exec(ctx context.Context, db DB) (sql.Result, error)
- func (b *Builder) GroupBy(fields ...string) *Builder
- func (b *Builder) Having(format string, values ...interface{}) *Builder
- func (b *Builder) Insert(table string, columns map[string]interface{}) *Builder
- func (b *Builder) InsertStruct(table string, i interface{}, ignoreZeroValue bool, ignoreFields ...string) *Builder
- func (b *Builder) OrderBy(fields ...string) *Builder
- func (b *Builder) Paging(page, size int) *Builder
- func (b *Builder) Query(ctx context.Context, db DB, i interface{}) error
- func (b *Builder) Select(table string, columns ...string) *Builder
- func (b *Builder) SelectStruct(table string, i interface{}, ignoreFields ...string) *Builder
- func (b *Builder) Update(table string, columns map[string]interface{}) *Builder
- func (b *Builder) UpdateStruct(table string, i interface{}, ignoreZeroValue bool, ignoreFields ...string) *Builder
- func (b *Builder) Where(format string, values ...interface{}) *Builder
- func (b *Builder) WhereIn(column string, values ...interface{}) *Builder
- type BuilderOptionFunc
- func Delete(table string) BuilderOptionFunc
- func GroupBy(fields ...string) BuilderOptionFunc
- func Having(format string, values ...interface{}) BuilderOptionFunc
- func Insert(table string, columns map[string]interface{}) BuilderOptionFunc
- func OrderBy(fields ...string) BuilderOptionFunc
- func Paging(page, size int) BuilderOptionFunc
- func Select(table string, columns ...string) BuilderOptionFunc
- func SelectStruct(table string, i interface{}, ignoreColumns ...string) BuilderOptionFunc
- func Update(table string, columns map[string]interface{}) BuilderOptionFunc
- func Where(format string, values ...interface{}) BuilderOptionFunc
- func WhereIn(column string, values ...interface{}) BuilderOptionFunc
- func WithDialect(d string) BuilderOptionFunc
- type BulkInsertBuilder
- func (b *BulkInsertBuilder) Append(values ...[]interface{}) *BulkInsertBuilder
- func (b *BulkInsertBuilder) AppendMap(mm ...map[string]interface{}) *BulkInsertBuilder
- func (b *BulkInsertBuilder) AppendStruct(ii ...interface{}) *BulkInsertBuilder
- func (b *BulkInsertBuilder) Build() (Template, error)
- func (b *BulkInsertBuilder) Columns(cc ...string) *BulkInsertBuilder
- func (b *BulkInsertBuilder) Dialect(name string) *BulkInsertBuilder
- func (b *BulkInsertBuilder) Table(name string) *BulkInsertBuilder
- type Column
- type Condition
- func (c Condition) Append(others ...Template) Condition
- func (c Condition) AppendIn(column string, values ...interface{}) Condition
- func (c Condition) AppendMap(m map[string]interface{}) Condition
- func (c Condition) AppendStruct(i interface{}, ignoreZeroValue bool) Condition
- func (c Condition) Appendf(format string, values ...interface{}) Condition
- func (c Condition) Join(sep string, right, left string) Template
- func (c Condition) JoinAnd() Template
- func (c Condition) JoinOr() Template
- type DB
- type DDLBuilder
- func (b *DDLBuilder) Build() Template
- func (b *DDLBuilder) Compact() *DDLBuilder
- func (b *DDLBuilder) CreateTable(table Table, checkExists bool) *DDLBuilder
- func (b *DDLBuilder) Dialect(name string) *DDLBuilder
- func (b *DDLBuilder) DropTable(table string, checkExists bool) *DDLBuilder
- func (b *DDLBuilder) Pretty(prefix string, indent string) *DDLBuilder
- type Dialect
- type Logger
- type Raw
- type Rows
- func (r *Rows) Bind(i interface{}) error
- func (r *Rows) Map() (map[string]interface{}, error)
- func (r *Rows) MapSlice() ([]map[string]interface{}, error)
- func (r *Rows) Scalar(value interface{}) error
- func (r *Rows) ScalarSlice(slice interface{}) error
- func (r *Rows) Scan(callback func(scan func(...interface{}) error, abort func()) error) error
- func (r *Rows) Struct(i interface{}) error
- func (r *Rows) StructSlice(i interface{}) error
- type Table
- type Template
- func (t Template) Append(others ...Template) Template
- func (t Template) AppendValues(values ...interface{}) Template
- func (t Template) Appendf(format string, values ...interface{}) Template
- func (t Template) Bracket() Template
- func (t Template) Empty() bool
- func (t Template) FirstValue() interface{}
- func (t Template) String() string
- func (t Template) Wrap(left string, right string) Template
- type Templates
Constants ¶
View Source
const ( TagKey = "bear" TagChildKeyName = "name" TagItemSep = "," TagKVSep = "=" )
Variables ¶
View Source
var ( ErrNotFoundDialect = errorf("not found dialect") ErrInvalidDialect = errorf("invalid dialect") )
Functions ¶
func EnableDebug ¶
func EnableDebug(b bool)
func GetStructFieldNames ¶
func GetStructFieldNames(i interface{}) []string
func RegisterDefaultDialect ¶
func RegisterDialect ¶
func SetDefaultDialect ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func NewBuilder ¶
func NewBuilder(options ...BuilderOptionFunc) *Builder
func (*Builder) Apply ¶
func (b *Builder) Apply(options ...BuilderOptionFunc) *Builder
func (*Builder) InsertStruct ¶
func (*Builder) SelectStruct ¶
func (*Builder) UpdateStruct ¶
type BuilderOptionFunc ¶
type BuilderOptionFunc func(b *Builder)
func Delete ¶
func Delete(table string) BuilderOptionFunc
func GroupBy ¶
func GroupBy(fields ...string) BuilderOptionFunc
func Having ¶
func Having(format string, values ...interface{}) BuilderOptionFunc
func Insert ¶
func Insert(table string, columns map[string]interface{}) BuilderOptionFunc
func OrderBy ¶
func OrderBy(fields ...string) BuilderOptionFunc
func Paging ¶
func Paging(page, size int) BuilderOptionFunc
func Select ¶
func Select(table string, columns ...string) BuilderOptionFunc
func SelectStruct ¶
func SelectStruct(table string, i interface{}, ignoreColumns ...string) BuilderOptionFunc
func Update ¶
func Update(table string, columns map[string]interface{}) BuilderOptionFunc
func Where ¶
func Where(format string, values ...interface{}) BuilderOptionFunc
func WhereIn ¶
func WhereIn(column string, values ...interface{}) BuilderOptionFunc
func WithDialect ¶
func WithDialect(d string) BuilderOptionFunc
type BulkInsertBuilder ¶
type BulkInsertBuilder struct {
// contains filtered or unexported fields
}
func NewBulkInsertBuilder ¶
func NewBulkInsertBuilder() *BulkInsertBuilder
func (*BulkInsertBuilder) Append ¶
func (b *BulkInsertBuilder) Append(values ...[]interface{}) *BulkInsertBuilder
func (*BulkInsertBuilder) AppendMap ¶
func (b *BulkInsertBuilder) AppendMap(mm ...map[string]interface{}) *BulkInsertBuilder
func (*BulkInsertBuilder) AppendStruct ¶
func (b *BulkInsertBuilder) AppendStruct(ii ...interface{}) *BulkInsertBuilder
func (*BulkInsertBuilder) Build ¶
func (b *BulkInsertBuilder) Build() (Template, error)
func (*BulkInsertBuilder) Columns ¶
func (b *BulkInsertBuilder) Columns(cc ...string) *BulkInsertBuilder
func (*BulkInsertBuilder) Dialect ¶
func (b *BulkInsertBuilder) Dialect(name string) *BulkInsertBuilder
func (*BulkInsertBuilder) Table ¶
func (b *BulkInsertBuilder) Table(name string) *BulkInsertBuilder
type Condition ¶
type Condition []Template
func NewCondition ¶
func (Condition) AppendStruct ¶
type DB ¶
type DDLBuilder ¶
type DDLBuilder struct {
// contains filtered or unexported fields
}
func NewDDLBuilder ¶
func NewDDLBuilder(dialect ...string) *DDLBuilder
func (*DDLBuilder) Build ¶
func (b *DDLBuilder) Build() Template
func (*DDLBuilder) Compact ¶
func (b *DDLBuilder) Compact() *DDLBuilder
func (*DDLBuilder) CreateTable ¶
func (b *DDLBuilder) CreateTable(table Table, checkExists bool) *DDLBuilder
func (*DDLBuilder) Dialect ¶
func (b *DDLBuilder) Dialect(name string) *DDLBuilder
func (*DDLBuilder) DropTable ¶
func (b *DDLBuilder) DropTable(table string, checkExists bool) *DDLBuilder
func (*DDLBuilder) Pretty ¶
func (b *DDLBuilder) Pretty(prefix string, indent string) *DDLBuilder
type Dialect ¶
func GetDefaultDialect ¶
func GetDefaultDialect() Dialect
func GetDialect ¶
func LookupDialect ¶
type Template ¶
type Template struct { Format string Values []interface{} }
func NewTemplate ¶
func (Template) AppendValues ¶
func (Template) FirstValue ¶
func (t Template) FirstValue() interface{}
type Templates ¶
type Templates []Template
func NewPlainTemplates ¶
func NewTemplates ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.