improve Order feature for package gdb

This commit is contained in:
John Guo 2021-06-23 09:42:10 +08:00
parent 816791b9c1
commit 7667aca4c2

View File

@ -277,6 +277,9 @@ func (m *Model) Order(orderBy ...string) *Model {
return m
}
model := m.getModel()
if model.orderBy != "" {
model.orderBy += ","
}
model.orderBy = m.db.GetCore().QuoteString(strings.Join(orderBy, " "))
return model
}
@ -287,6 +290,9 @@ func (m *Model) OrderAsc(column string) *Model {
return m
}
model := m.getModel()
if model.orderBy != "" {
model.orderBy += ","
}
model.orderBy = m.db.GetCore().QuoteWord(column) + " ASC"
return model
}
@ -297,6 +303,9 @@ func (m *Model) OrderDesc(column string) *Model {
return m
}
model := m.getModel()
if model.orderBy != "" {
model.orderBy += ","
}
model.orderBy = m.db.GetCore().QuoteWord(column) + " DESC"
return model
}