feat(order): support call Order once to order by multi fields
This commit is contained in:
parent
3a3b82263a
commit
0c66383e6a
@ -219,6 +219,12 @@ func (db *DB) Order(value interface{}) (tx *DB) {
|
|||||||
tx.Statement.AddClause(clause.OrderBy{
|
tx.Statement.AddClause(clause.OrderBy{
|
||||||
Columns: []clause.OrderByColumn{v},
|
Columns: []clause.OrderByColumn{v},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case clause.OrderByColumns:
|
||||||
|
tx.Statement.AddClause(clause.OrderBy{
|
||||||
|
Columns: v,
|
||||||
|
})
|
||||||
|
|
||||||
case string:
|
case string:
|
||||||
if v != "" {
|
if v != "" {
|
||||||
tx.Statement.AddClause(clause.OrderBy{
|
tx.Statement.AddClause(clause.OrderBy{
|
||||||
|
@ -6,6 +6,8 @@ type OrderByColumn struct {
|
|||||||
Reorder bool
|
Reorder bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OrderByColumns = []OrderByColumn
|
||||||
|
|
||||||
type OrderBy struct {
|
type OrderBy struct {
|
||||||
Columns []OrderByColumn
|
Columns []OrderByColumn
|
||||||
Expression Expression
|
Expression Expression
|
||||||
|
Loading…
x
Reference in New Issue
Block a user