mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-07-19 01:48:42 +08:00
20 lines
384 B
Go
20 lines
384 B
Go
package db
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/OpenListTeam/OpenList/v4/internal/conf"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
func columnName(name string) string {
|
|
if conf.Conf.Database.Type == "postgres" {
|
|
return fmt.Sprintf(`"%s"`, name)
|
|
}
|
|
return fmt.Sprintf("`%s`", name)
|
|
}
|
|
|
|
func addStorageOrder(db *gorm.DB) *gorm.DB {
|
|
return db.Order(fmt.Sprintf("%s, %s", columnName("order"), columnName("id")))
|
|
}
|