From 7547246bec0c19a1e2bfd883252f41789d96256b Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Sun, 17 Sep 2023 18:17:22 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=ED=94=84=EB=A0=88=EC=8A=A4=EC=84=BC?= =?UTF-8?q?=ED=84=B0=20=EB=B0=8F=20=EA=B2=8C=EC=8B=9C=ED=8C=90=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=88=9C=EC=84=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/hicardipresscenter/global/QueryUtil.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/hicardipresscenter/global/QueryUtil.java b/src/main/java/com/example/hicardipresscenter/global/QueryUtil.java index de6e075..38e2213 100644 --- a/src/main/java/com/example/hicardipresscenter/global/QueryUtil.java +++ b/src/main/java/com/example/hicardipresscenter/global/QueryUtil.java @@ -1,6 +1,7 @@ package com.example.hicardipresscenter.global; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; @@ -26,7 +27,8 @@ public static Query getQueryWithDate(Pageable pageable, String option, String cr .limit(pageable.getPageSize()); } - return query; + // desc by id + return query.with(Sort.by(Sort.Direction.DESC, "_id")); } public static Query getQuery(Pageable pageable, String criteria, String keyword) { @@ -46,7 +48,7 @@ public static Query getQuery(Pageable pageable, String criteria, String keyword) .limit(pageable.getPageSize()); } - return query; + return query.with(Sort.by(Sort.Direction.DESC, "_id")); } public static Query getTotalQuery(String criteria, String keyword) {