Documentation ¶
Index ¶
- Constants
- func BatchDoList(db sqlx.DBExecutor, scanners ...DataList) (err error)
- func ContextWithIgnoreDeletedAt(ctx context.Context) context.Context
- func Excluded(f *builder.Column) builder.SqlExpr
- func ExcludedFields(fields ...*builder.Column) builder.Assignments
- func FilterAdditions(additions builder.Additions, filter func(a builder.Addition) bool) builder.Additions
- func ToCondition(db sqlx.DBExecutor, b ConditionBuilder) builder.SqlCondition
- type BuildSubExpr
- type Collection
- func (c *Collection) DoList(db sqlx.DBExecutor, pager *Pager, additions ...builder.Addition) error
- func (c *Collection) Init(new func() interface{}, id func(v interface{}) interface{}, ...)
- func (c *Collection) New() interface{}
- func (c *Collection) Next(v interface{}) error
- func (c *Collection) OnNext(id interface{}, receivers ...Receiver)
- func (c *Collection) ToCondition(db sqlx.DBExecutor) builder.SqlCondition
- type ConditionBuilder
- func AllOf(builders ...ConditionBuilder) ConditionBuilder
- func ConditionBuilderBy(build func(db sqlx.DBExecutor) builder.SqlCondition) ConditionBuilder
- func ConditionBuilderFromCondition(c builder.SqlCondition) ConditionBuilder
- func OneOf(builders ...ConditionBuilder) ConditionBuilder
- func SubSelect(target *builder.Column, subConditionBuilder SubConditionBuilder) ConditionBuilder
- type CouldScan
- type Counter
- type DataList
- type ModalAndWithQuery
- type ModelWithCreatedAt
- type ModelWithDeletedAt
- type ModelWithPrimaryKey
- type ModelWithUniqueIndexes
- type ModelWithUpdatedAt
- type Pager
- type Receiver
- type RecordCollection
- func (vc *RecordCollection) AsAssignments() builder.Assignments
- func (vc *RecordCollection) IsNil() bool
- func (vc *RecordCollection) SetRecordValues(values ...interface{})
- func (vc *RecordCollection) Values() []interface{}
- func (vc RecordCollection) WithExtendCol(col *builder.Column, val interface{}) *RecordCollection
- type RecordValues
- type Stmt
- func (s *Stmt) Delete(model builder.Model) *StmtDelete
- func (s *Stmt) ExprBy(do func(ctx context.Context) *builder.Ex) builder.SqlExpr
- func (s *Stmt) Insert() *StmtInsert
- func (s *Stmt) ReturningOf(expr builder.SqlExpr, target builder.SqlExpr) CouldScan
- func (s *Stmt) Select(target builder.SqlExpr) *StmtSelect
- func (s *Stmt) T(model builder.Model) *builder.Table
- func (s *Stmt) Update(model builder.Model, modifiers ...string) *StmtUpdate
- func (s Stmt) With(model ModalAndWithQuery, others ...ModalAndWithQuery) *Stmt
- type StmtDelete
- func (s *StmtDelete) Do() error
- func (s *StmtDelete) Ex(ctx context.Context) *builder.Ex
- func (s StmtDelete) From(model builder.Model) *StmtDelete
- func (s *StmtDelete) IsNil() bool
- func (s *StmtDelete) Returning(target builder.SqlExpr) CouldScan
- func (s StmtDelete) Where(where builder.SqlCondition) *StmtDelete
- type StmtInsert
- func (s *StmtInsert) Do() error
- func (s *StmtInsert) Ex(ctx context.Context) *builder.Ex
- func (s StmtInsert) Into(model builder.Model, additions ...builder.Addition) *StmtInsert
- func (s *StmtInsert) IsNil() bool
- func (s StmtInsert) OnConflictDoNothing(indexKey string) *StmtInsert
- func (s StmtInsert) OnConflictDoUpdateSet(indexKey string, excludedColumns ...*builder.Column) *StmtInsert
- func (s *StmtInsert) Returning(target builder.SqlExpr) CouldScan
- func (s StmtInsert) ValuesBy(collect func(vc *RecordCollection), columns ...*builder.Column) *StmtInsert
- func (s StmtInsert) ValuesFrom(model builder.Model, columnsCouldBeZeroValue ...*builder.Column) *StmtInsert
- func (s StmtInsert) ValuesWith(recordValues RecordValues, columns ...*builder.Column) *StmtInsert
- type StmtSelect
- func (s StmtSelect) CrossJoin(target builder.Model) *StmtSelect
- func (s *StmtSelect) Ex(ctx context.Context) *builder.Ex
- func (s StmtSelect) From(model builder.Model) *StmtSelect
- func (s StmtSelect) FullJoin(target builder.Model, joinCondition builder.SqlCondition) *StmtSelect
- func (s *StmtSelect) IsNil() bool
- func (s StmtSelect) Join(target builder.Model, joinCondition builder.SqlCondition) *StmtSelect
- func (s StmtSelect) LeftJoin(target builder.Model, joinCondition builder.SqlCondition) *StmtSelect
- func (s *StmtSelect) List(list sqlx.ScanIterator, pager *Pager) error
- func (s StmtSelect) RightJoin(target builder.Model, joinCondition builder.SqlCondition) *StmtSelect
- func (s *StmtSelect) Scan(v interface{}) error
- func (s StmtSelect) Where(where builder.SqlCondition, additions ...builder.Addition) *StmtSelect
- type StmtUpdate
- func (s *StmtUpdate) Do() error
- func (s *StmtUpdate) Ex(ctx context.Context) *builder.Ex
- func (s StmtUpdate) From(from builder.Model) *StmtUpdate
- func (s *StmtUpdate) IsNil() bool
- func (s *StmtUpdate) Returning(target builder.SqlExpr) CouldScan
- func (s StmtUpdate) SetBy(collect func(vc *RecordCollection), columns ...*builder.Column) *StmtUpdate
- func (s StmtUpdate) SetFrom(model builder.Model, columnsCouldBeZeroValue ...*builder.Column) *StmtUpdate
- func (s StmtUpdate) SetWith(recordValues RecordValues, columns ...*builder.Column) *StmtUpdate
- func (s StmtUpdate) Where(where builder.SqlCondition) *StmtUpdate
- type StmtWith
- type SubConditionBuilder
- type WithCountExpr
- type WithRecursive
- type WithTotal
Constants ¶
View Source
const PrimaryKey = "pk"
Variables ¶
This section is empty.
Functions ¶
func BatchDoList ¶
func ExcludedFields ¶
func ExcludedFields(fields ...*builder.Column) builder.Assignments
func FilterAdditions ¶ added in v1.6.0
func ToCondition ¶
func ToCondition(db sqlx.DBExecutor, b ConditionBuilder) builder.SqlCondition
Types ¶
type BuildSubExpr ¶
type Collection ¶ added in v1.7.0
type Collection struct {
// contains filtered or unexported fields
}
func (*Collection) DoList ¶ added in v1.7.0
func (c *Collection) DoList(db sqlx.DBExecutor, pager *Pager, additions ...builder.Addition) error
func (*Collection) Init ¶ added in v1.7.0
func (c *Collection) Init(new func() interface{}, id func(v interface{}) interface{}, condition func(db sqlx.DBExecutor, ids []interface{}) builder.SqlCondition)
func (*Collection) New ¶ added in v1.7.0
func (c *Collection) New() interface{}
func (*Collection) Next ¶ added in v1.7.0
func (c *Collection) Next(v interface{}) error
func (*Collection) OnNext ¶ added in v1.7.0
func (c *Collection) OnNext(id interface{}, receivers ...Receiver)
func (*Collection) ToCondition ¶ added in v1.7.0
func (c *Collection) ToCondition(db sqlx.DBExecutor) builder.SqlCondition
type ConditionBuilder ¶
type ConditionBuilder interface {
ToCondition(db sqlx.DBExecutor) builder.SqlCondition
}
func AllOf ¶ added in v1.5.0
func AllOf(builders ...ConditionBuilder) ConditionBuilder
func ConditionBuilderBy ¶ added in v1.5.0
func ConditionBuilderBy(build func(db sqlx.DBExecutor) builder.SqlCondition) ConditionBuilder
func ConditionBuilderFromCondition ¶
func ConditionBuilderFromCondition(c builder.SqlCondition) ConditionBuilder
func OneOf ¶ added in v1.5.0
func OneOf(builders ...ConditionBuilder) ConditionBuilder
func SubSelect ¶ added in v1.5.0
func SubSelect(target *builder.Column, subConditionBuilder SubConditionBuilder) ConditionBuilder
type DataList ¶
type DataList interface { sqlx.ScanIterator ConditionBuilder DoList(db sqlx.DBExecutor, pager *Pager, additions ...builder.Addition) error }
type ModalAndWithQuery ¶ added in v1.1.0
func AsWithQuery ¶ added in v1.1.0
func AsWithQuery(model builder.Model, withQueryFn func(db sqlx.DBExecutor) builder.SqlExpr) ModalAndWithQuery
func AsWithRecursiveQuery ¶ added in v1.1.0
func AsWithRecursiveQuery(model builder.Model, withQueryFn func(db sqlx.DBExecutor) builder.SqlExpr) ModalAndWithQuery
type ModelWithCreatedAt ¶
type ModelWithDeletedAt ¶
type ModelWithPrimaryKey ¶
type ModelWithUniqueIndexes ¶
type ModelWithUpdatedAt ¶
type RecordCollection ¶
func RecordCollectionBy ¶
func RecordCollectionBy(collect func(rc *RecordCollection), columns ...*builder.Column) *RecordCollection
func RecordCollectionFrom ¶
func RecordCollectionFrom(db sqlx.DBExecutor, model builder.Model, columnsCouldBeZeroValue ...*builder.Column) *RecordCollection
func RecordCollectionWith ¶
func RecordCollectionWith(recordValues RecordValues, columns ...*builder.Column) *RecordCollection
func (*RecordCollection) AsAssignments ¶
func (vc *RecordCollection) AsAssignments() builder.Assignments
func (*RecordCollection) IsNil ¶
func (vc *RecordCollection) IsNil() bool
func (*RecordCollection) SetRecordValues ¶
func (vc *RecordCollection) SetRecordValues(values ...interface{})
func (*RecordCollection) Values ¶
func (vc *RecordCollection) Values() []interface{}
func (RecordCollection) WithExtendCol ¶
func (vc RecordCollection) WithExtendCol(col *builder.Column, val interface{}) *RecordCollection
type RecordValues ¶
type RecordValues []interface{}
type Stmt ¶
type Stmt struct {
// contains filtered or unexported fields
}
func (*Stmt) Insert ¶
func (s *Stmt) Insert() *StmtInsert
func (*Stmt) ReturningOf ¶
func (Stmt) With ¶
func (s Stmt) With(model ModalAndWithQuery, others ...ModalAndWithQuery) *Stmt
type StmtDelete ¶
type StmtDelete struct {
// contains filtered or unexported fields
}
* [ WITH [ RECURSIVE ] with_query [, ...] ] DELETE FROM [ ONLY ] table_name [ * ] [ [ AS ] alias ]
[ USING using_list ] [ WHERE condition | WHERE CURRENT OF cursor_name ] [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]
func (*StmtDelete) Do ¶
func (s *StmtDelete) Do() error
func (StmtDelete) From ¶
func (s StmtDelete) From(model builder.Model) *StmtDelete
func (*StmtDelete) IsNil ¶
func (s *StmtDelete) IsNil() bool
func (StmtDelete) Where ¶
func (s StmtDelete) Where(where builder.SqlCondition) *StmtDelete
type StmtInsert ¶
type StmtInsert struct {
// contains filtered or unexported fields
}
* [ WITH [ RECURSIVE ] with_query [, ...] ] INSERT INTO table_name [ AS alias ] [ ( column_name [, ...] ) ]
[ OVERRIDING { SYSTEM | USER} VALUE ] { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query } [ ON CONFLICT [ conflict_target ] conflict_action ] [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]
where conflict_target can be one of:
( { index_column_name | ( index_expression ) } [ COLLATE collation ] [ opclass ] [, ...] ) [ WHERE index_predicate ] ON CONSTRAINT constraint_name
and conflict_action is one of:
DO NOTHING DO UPDATE SET { column_name = { expression | DEFAULT } | ( column_name [, ...] ) = [ ROW ] ( { expression | DEFAULT } [, ...] ) | ( column_name [, ...] ) = ( sub-SELECT ) } [, ...] [ WHERE condition ]
func (*StmtInsert) Do ¶
func (s *StmtInsert) Do() error
func (StmtInsert) Into ¶
func (s StmtInsert) Into(model builder.Model, additions ...builder.Addition) *StmtInsert
func (*StmtInsert) IsNil ¶
func (s *StmtInsert) IsNil() bool
func (StmtInsert) OnConflictDoNothing ¶
func (s StmtInsert) OnConflictDoNothing(indexKey string) *StmtInsert
func (StmtInsert) OnConflictDoUpdateSet ¶
func (s StmtInsert) OnConflictDoUpdateSet(indexKey string, excludedColumns ...*builder.Column) *StmtInsert
func (StmtInsert) ValuesBy ¶
func (s StmtInsert) ValuesBy(collect func(vc *RecordCollection), columns ...*builder.Column) *StmtInsert
func (StmtInsert) ValuesFrom ¶
func (s StmtInsert) ValuesFrom(model builder.Model, columnsCouldBeZeroValue ...*builder.Column) *StmtInsert
func (StmtInsert) ValuesWith ¶
func (s StmtInsert) ValuesWith(recordValues RecordValues, columns ...*builder.Column) *StmtInsert
type StmtSelect ¶
type StmtSelect struct { builder.SelectStatement // contains filtered or unexported fields }
* [ WITH [ RECURSIVE ] with_query [, ...] ] SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
[ * | expression [ [ AS ] output_name ] [, ...] ] [ FROM from_item [, ...] ] [ WHERE condition ] [ GROUP BY grouping_element [, ...] ] [ HAVING condition [, ...] ] [ WINDOW window_name AS ( window_definition ) [, ...] ] [ { UNION | INTERSECT | EXCEPT } [ ALL | DISTINCT ] select ] [ ORDER BY expression [ ASC | DESC | USING operator ] [ NULLS { FIRST | LAST } ] [, ...] ] [ LIMIT { count | ALL } ] [ OFFSET start [ ROW | ROWS ] ] [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ] [ FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF table_name [, ...] ] [ NOWAIT | SKIP LOCKED ] [...] ]
where from_item can be one of:
[ ONLY ] table_name [ * ] [ [ AS ] alias [ ( column_alias [, ...] ) ] ] [ TABLESAMPLE sampling_method ( argument [, ...] ) [ REPEATABLE ( seed ) ] ] [ LATERAL ] ( select ) [ AS ] alias [ ( column_alias [, ...] ) ] with_query_name [ [ AS ] alias [ ( column_alias [, ...] ) ] ] [ LATERAL ] function_name ( [ argument [, ...] ] ) [ WITH ORDINALITY ] [ [ AS ] alias [ ( column_alias [, ...] ) ] ] [ LATERAL ] function_name ( [ argument [, ...] ] ) [ AS ] alias ( column_definition [, ...] ) [ LATERAL ] function_name ( [ argument [, ...] ] ) AS ( column_definition [, ...] ) [ LATERAL ] ROWS FROM( function_name ( [ argument [, ...] ] ) [ AS ( column_definition [, ...] ) ] [, ...] ) [ WITH ORDINALITY ] [ [ AS ] alias [ ( column_alias [, ...] ) ] ] from_item [ NATURAL ] join_type from_item [ ON join_condition | USING ( join_column [, ...] ) ]
and grouping_element can be one of:
( ) expression ( expression [, ...] ) ROLLUP ( { expression | ( expression [, ...] ) } [, ...] ) CUBE ( { expression | ( expression [, ...] ) } [, ...] ) GROUPING SETS ( grouping_element [, ...] )
and with_query is:
with_query_name [ ( column_name [, ...] ) ] AS ( select | values | insert | update | delete )
TABLE [ ONLY ] table_name [ * ]
func (StmtSelect) CrossJoin ¶
func (s StmtSelect) CrossJoin(target builder.Model) *StmtSelect
func (StmtSelect) From ¶
func (s StmtSelect) From(model builder.Model) *StmtSelect
func (StmtSelect) FullJoin ¶
func (s StmtSelect) FullJoin(target builder.Model, joinCondition builder.SqlCondition) *StmtSelect
func (*StmtSelect) IsNil ¶
func (s *StmtSelect) IsNil() bool
func (StmtSelect) Join ¶
func (s StmtSelect) Join(target builder.Model, joinCondition builder.SqlCondition) *StmtSelect
func (StmtSelect) LeftJoin ¶
func (s StmtSelect) LeftJoin(target builder.Model, joinCondition builder.SqlCondition) *StmtSelect
func (*StmtSelect) List ¶
func (s *StmtSelect) List(list sqlx.ScanIterator, pager *Pager) error
func (StmtSelect) RightJoin ¶
func (s StmtSelect) RightJoin(target builder.Model, joinCondition builder.SqlCondition) *StmtSelect
func (*StmtSelect) Scan ¶
func (s *StmtSelect) Scan(v interface{}) error
func (StmtSelect) Where ¶
func (s StmtSelect) Where(where builder.SqlCondition, additions ...builder.Addition) *StmtSelect
type StmtUpdate ¶
type StmtUpdate struct {
// contains filtered or unexported fields
}
* [ WITH [ RECURSIVE ] with_query [, ...] ] UPDATE [ ONLY ] table_name [ * ] [ [ AS ] alias ]
SET { column_name = { expression | DEFAULT } | ( column_name [, ...] ) = [ ROW ] ( { expression | DEFAULT } [, ...] ) | ( column_name [, ...] ) = ( sub-SELECT ) } [, ...] [ FROM from_list ] [ WHERE condition | WHERE CURRENT OF cursor_name ] [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]
func (*StmtUpdate) Do ¶
func (s *StmtUpdate) Do() error
func (StmtUpdate) From ¶ added in v1.3.0
func (s StmtUpdate) From(from builder.Model) *StmtUpdate
func (*StmtUpdate) IsNil ¶
func (s *StmtUpdate) IsNil() bool
func (StmtUpdate) SetBy ¶
func (s StmtUpdate) SetBy(collect func(vc *RecordCollection), columns ...*builder.Column) *StmtUpdate
func (StmtUpdate) SetFrom ¶
func (s StmtUpdate) SetFrom(model builder.Model, columnsCouldBeZeroValue ...*builder.Column) *StmtUpdate
func (StmtUpdate) SetWith ¶
func (s StmtUpdate) SetWith(recordValues RecordValues, columns ...*builder.Column) *StmtUpdate
func (StmtUpdate) Where ¶
func (s StmtUpdate) Where(where builder.SqlCondition) *StmtUpdate
type SubConditionBuilder ¶ added in v1.5.0
type SubConditionBuilder interface { ConditionBuilder SelectFrom(db sqlx.DBExecutor) *StmtSelect }
type WithCountExpr ¶
type WithRecursive ¶ added in v1.1.0
type WithRecursive interface {
// contains filtered or unexported methods
}
Click to show internal directories.
Click to hide internal directories.