restructuring of files. added 2 new methods(Asc, Desc) to field
This commit is contained in:
133
qry_select.go
133
qry_select.go
@@ -14,6 +14,120 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
SelectClause interface {
|
||||
// Join and Inner Join are same
|
||||
Join(m Table, t1Field, t2Field Field, cond ...Conditioner) SelectClause
|
||||
LeftJoin(m Table, t1Field, t2Field Field, cond ...Conditioner) SelectClause
|
||||
RightJoin(m Table, t1Field, t2Field Field, cond ...Conditioner) SelectClause
|
||||
FullJoin(m Table, t1Field, t2Field Field, cond ...Conditioner) SelectClause
|
||||
CrossJoin(m Table) SelectClause
|
||||
WhereClause
|
||||
OrderByClause
|
||||
GroupByClause
|
||||
LimitClause
|
||||
OffsetClause
|
||||
Query
|
||||
raw(prefixArgs []any) (string, []any)
|
||||
}
|
||||
|
||||
WhereClause interface {
|
||||
Where(cond ...Conditioner) AfterWhere
|
||||
}
|
||||
|
||||
AfterWhere interface {
|
||||
WhereClause
|
||||
GroupByClause
|
||||
OrderByClause
|
||||
LimitClause
|
||||
OffsetClause
|
||||
Query
|
||||
}
|
||||
|
||||
GroupByClause interface {
|
||||
GroupBy(fields ...Field) AfterGroupBy
|
||||
}
|
||||
|
||||
AfterGroupBy interface {
|
||||
HavinClause
|
||||
OrderByClause
|
||||
LimitClause
|
||||
OffsetClause
|
||||
Query
|
||||
}
|
||||
|
||||
HavinClause interface {
|
||||
Having(cond ...Conditioner) AfterHaving
|
||||
}
|
||||
|
||||
AfterHaving interface {
|
||||
OrderByClause
|
||||
LimitClause
|
||||
OffsetClause
|
||||
Query
|
||||
}
|
||||
|
||||
OrderByClause interface {
|
||||
OrderBy(fields ...Field) AfterOrderBy
|
||||
}
|
||||
|
||||
AfterOrderBy interface {
|
||||
LimitClause
|
||||
OffsetClause
|
||||
Query
|
||||
}
|
||||
|
||||
LimitClause interface {
|
||||
Limit(v int) AfterLimit
|
||||
}
|
||||
|
||||
AfterLimit interface {
|
||||
OffsetClause
|
||||
Query
|
||||
}
|
||||
|
||||
OffsetClause interface {
|
||||
Offset(v int) AfterOffset
|
||||
}
|
||||
|
||||
AfterOffset interface {
|
||||
LimitClause
|
||||
Query
|
||||
}
|
||||
|
||||
Do interface {
|
||||
DoNothing() Execute
|
||||
DoUpdate(fields ...Field) Execute
|
||||
}
|
||||
|
||||
Query interface {
|
||||
First
|
||||
All
|
||||
Stringer
|
||||
}
|
||||
|
||||
RowScanner interface {
|
||||
Scan(dest ...any) error
|
||||
}
|
||||
|
||||
RowsCb func(row RowScanner) error
|
||||
|
||||
First interface {
|
||||
First(ctx context.Context, dest ...any) error
|
||||
FirstTx(ctx context.Context, tx pgx.Tx, dest ...any) error
|
||||
Stringer
|
||||
}
|
||||
|
||||
All interface {
|
||||
// Query rows
|
||||
//
|
||||
// don't forget to close() rows
|
||||
All(ctx context.Context, rows RowsCb) error
|
||||
// Query rows
|
||||
//
|
||||
// don't forget to close() rows
|
||||
AllTx(ctx context.Context, tx pgx.Tx, rows RowsCb) error
|
||||
}
|
||||
|
||||
selectQry struct {
|
||||
table string
|
||||
fields []Field
|
||||
@@ -23,9 +137,11 @@ type (
|
||||
groupBy []Field
|
||||
having []Conditioner
|
||||
orderBy []Field
|
||||
limit int
|
||||
offset int
|
||||
debug bool
|
||||
|
||||
limit int
|
||||
offset int
|
||||
|
||||
debug bool
|
||||
}
|
||||
|
||||
CondAction uint8
|
||||
@@ -51,17 +167,6 @@ const (
|
||||
CondActionSubQuery
|
||||
)
|
||||
|
||||
// Select clause
|
||||
func (t Table) Select(field ...Field) SelectClause {
|
||||
qb := &selectQry{
|
||||
table: t.Name,
|
||||
debug: t.debug,
|
||||
fields: field,
|
||||
}
|
||||
|
||||
return qb
|
||||
}
|
||||
|
||||
func (q *selectQry) Join(t Table, t1Field, t2Field Field, cond ...Conditioner) SelectClause {
|
||||
return q.buildJoin(t, "JOIN", t1Field, t2Field, cond...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user