From 948b53393aa7e845ffc45a6ad523f930708b0447 Mon Sep 17 00:00:00 2001 From: boojack Date: Sun, 22 May 2022 12:35:57 +0800 Subject: [PATCH] chore: add default `ORDER BY` --- store/memo.go | 3 ++- store/resource.go | 3 ++- store/shortcut.go | 3 ++- store/user.go | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/store/memo.go b/store/memo.go index 3e7269e..9a62648 100644 --- a/store/memo.go +++ b/store/memo.go @@ -219,7 +219,8 @@ func findMemoRawList(db *sql.DB, find *api.MemoFind) ([]*memoRaw, error) { content, row_status FROM memo - WHERE `+strings.Join(where, " AND "), + WHERE `+strings.Join(where, " AND ")+` + ORDER BY created_ts DESC`, args..., ) if err != nil { diff --git a/store/resource.go b/store/resource.go index 94804ef..230480d 100644 --- a/store/resource.go +++ b/store/resource.go @@ -154,7 +154,8 @@ func findResourceList(db *sql.DB, find *api.ResourceFind) ([]*resourceRaw, error created_ts, updated_ts FROM resource - WHERE `+strings.Join(where, " AND "), + WHERE `+strings.Join(where, " AND ")+` + ORDER BY created_ts DESC`, args..., ) if err != nil { diff --git a/store/shortcut.go b/store/shortcut.go index f9f5ee3..0cd583c 100644 --- a/store/shortcut.go +++ b/store/shortcut.go @@ -202,7 +202,8 @@ func findShortcutList(db *sql.DB, find *api.ShortcutFind) ([]*shortcutRaw, error updated_ts, row_status FROM shortcut - WHERE `+strings.Join(where, " AND "), + WHERE `+strings.Join(where, " AND ")+` + ORDER BY created_ts DESC`, args..., ) if err != nil { diff --git a/store/user.go b/store/user.go index 9735ad1..559c255 100644 --- a/store/user.go +++ b/store/user.go @@ -219,7 +219,8 @@ func findUserList(db *sql.DB, find *api.UserFind) ([]*userRaw, error) { created_ts, updated_ts FROM user - WHERE `+strings.Join(where, " AND "), + WHERE `+strings.Join(where, " AND ")+` + ORDER BY created_ts DESC`, args..., ) if err != nil {