feat(order): support call Order once to order by multi fields

This commit is contained in:
bestgopher 2021-11-30 21:44:10 +08:00
parent 3a3b82263a
commit 0c66383e6a
2 changed files with 8 additions and 0 deletions

View File

@ -219,6 +219,12 @@ func (db *DB) Order(value interface{}) (tx *DB) {
tx.Statement.AddClause(clause.OrderBy{
Columns: []clause.OrderByColumn{v},
})
case clause.OrderByColumns:
tx.Statement.AddClause(clause.OrderBy{
Columns: v,
})
case string:
if v != "" {
tx.Statement.AddClause(clause.OrderBy{

View File

@ -6,6 +6,8 @@ type OrderByColumn struct {
Reorder bool
}
type OrderByColumns = []OrderByColumn
type OrderBy struct {
Columns []OrderByColumn
Expression Expression