From 1b24031833d1947f5a11005aff2a8d71d079ad0b Mon Sep 17 00:00:00 2001 From: jusax23 Date: Sun, 2 Apr 2023 16:39:38 +0200 Subject: [PATCH] getItems sort --- src/api/acts/roomContent.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/acts/roomContent.ts b/src/api/acts/roomContent.ts index 7abfb7c..b81a07e 100644 --- a/src/api/acts/roomContent.ts +++ b/src/api/acts/roomContent.ts @@ -1,4 +1,4 @@ -import { and, coalesce, eq, insert, max, order, plus, remove, select, update } from "dblang"; +import { and, coalesce, eq, insert, leftJoinUsing, max, order, plus, remove, select, update } from "dblang"; import { checkSelfTag } from "../../server/outbagURL.js"; import { Act, Client, STATE } from "../user.js"; import { db, listCategories, listItems, listProducts } from "../../sys/db.js"; @@ -497,8 +497,10 @@ export const getItems: Act = { listItems.unit, listItems.value, listItems.link, - ], listItems) + ], leftJoinUsing(listItems, listCategories, listItems.category, listCategories.listCatID)) .where(eq(listItems.roomID, roomID)) + .orderBY(listItems.state, order.ASC) + .addOrderBy(listCategories.weight, order.ASC) .query(db); let out = req.map(d => { let listItemID = Number(d[listItems.listItemID]);