mirror of https://github.com/go-gorm/gorm.git
feat: chainable order support clause.OrderBy (#7054)
* feat: chainable order support clause.OrderBy * indent
This commit is contained in:
parent
49d94c173c
commit
49d524aaea
|
@ -299,10 +299,16 @@ func (db *DB) Having(query interface{}, args ...interface{}) (tx *DB) {
|
|||
//
|
||||
// db.Order("name DESC")
|
||||
// db.Order(clause.OrderByColumn{Column: clause.Column{Name: "name"}, Desc: true})
|
||||
// db.Order(clause.OrderBy{Columns: []clause.OrderByColumn{
|
||||
// {Column: clause.Column{Name: "name"}, Desc: true},
|
||||
// {Column: clause.Column{Name: "age"}, Desc: true},
|
||||
// }})
|
||||
func (db *DB) Order(value interface{}) (tx *DB) {
|
||||
tx = db.getInstance()
|
||||
|
||||
switch v := value.(type) {
|
||||
case clause.OrderBy:
|
||||
tx.Statement.AddClause(v)
|
||||
case clause.OrderByColumn:
|
||||
tx.Statement.AddClause(clause.OrderBy{
|
||||
Columns: []clause.OrderByColumn{v},
|
||||
|
|
Loading…
Reference in New Issue