getItems sort

This commit is contained in:
jusax23 2023-04-02 16:39:38 +02:00
parent b00a14a9c2
commit 1b24031833
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41

View file

@ -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 { checkSelfTag } from "../../server/outbagURL.js";
import { Act, Client, STATE } from "../user.js"; import { Act, Client, STATE } from "../user.js";
import { db, listCategories, listItems, listProducts } from "../../sys/db.js"; import { db, listCategories, listItems, listProducts } from "../../sys/db.js";
@ -497,8 +497,10 @@ export const getItems: Act = {
listItems.unit, listItems.unit,
listItems.value, listItems.value,
listItems.link, listItems.link,
], listItems) ], leftJoinUsing(listItems, listCategories, listItems.category, listCategories.listCatID))
.where(eq(listItems.roomID, roomID)) .where(eq(listItems.roomID, roomID))
.orderBY(listItems.state, order.ASC)
.addOrderBy(listCategories.weight, order.ASC)
.query(db); .query(db);
let out = req.map(d => { let out = req.map(d => {
let listItemID = Number(d[listItems.listItemID]); let listItemID = Number(d[listItems.listItemID]);