feat(guide): proper order sorting & hidden

This commit is contained in:
2026-03-19 01:28:55 +07:00 Unverified
parent db21e3cea4
commit 3c04403076
6 changed files with 53 additions and 18 deletions
+9 -4
View File
@@ -1,13 +1,18 @@
"use server";
import { ilike } from "drizzle-orm";
import { and, desc, ilike, not } from "drizzle-orm";
import { db } from "@/lib/db";
import { guides } from "@/lib/db/schema";
export async function searchGuide(search: string = "") {
export async function searchGuide(search: string = "", admin = false) {
return await db
.select()
.from(guides)
.where(ilike(guides.name, `%${search}%`))
.orderBy(guides.id);
.where(
and(
ilike(guides.name, `%${search}%`),
admin ? undefined : not(guides.hidden),
),
)
.orderBy(desc(guides.order));
}
+1 -1
View File
@@ -2,6 +2,6 @@ import { searchGuide } from "./api";
import { GuideList } from "./client";
export default async function GuidePage() {
const initialData = await searchGuide();
const initialData = await searchGuide("");
return <GuideList initialList={initialData} />;
}