default weight

This commit is contained in:
jusax23 2023-03-24 21:31:55 +01:00
parent e0011ae7ca
commit e45be71606
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41
3 changed files with 14 additions and 11 deletions

6
package-lock.json generated
View file

@ -12,7 +12,7 @@
"auth-header": "^1.0.0",
"commander": "^10.0.0",
"cors": "^2.8.5",
"dblang": "https://jusax.de/git/attachments/1317588b-b3f3-4b95-bdcc-34292a023298",
"dblang": "https://jusax.de/git/attachments/377d0a32-3eca-4a8f-9c3a-f8a045a9c5b1",
"express": "^4.18.2",
"juml": "https://jusax.de/git/attachments/208913c5-2851-4b86-a53d-ca99fed168cc",
"nman": "https://jusax.de/git/attachments/5333948b-fe6b-45d2-9230-ca388f6a89bc",
@ -1108,8 +1108,8 @@
},
"node_modules/dblang": {
"version": "0.9.3",
"resolved": "https://jusax.de/git/attachments/1317588b-b3f3-4b95-bdcc-34292a023298",
"integrity": "sha512-l2LKpxM79S2UjVWS1W9flLt6uZcVsG2qrc6JwqoFv0rgxMOBzoJnnWaHSD5UJKydgXjMycZIvXpGzkuX6vNfwA==",
"resolved": "https://jusax.de/git/attachments/377d0a32-3eca-4a8f-9c3a-f8a045a9c5b1",
"integrity": "sha512-Co3RZ2Dfk2Atm2Oyr7rtHJDeiMZ8NwfrvTBwfhP9wVkXQuN1WrMMQ5W+/Ho2g6c6BWbUnsqADKTaCcJZrYBbjQ==",
"license": "UNLICENSED",
"dependencies": {
"gitea-release": "git+https://jusax.de/git/jusax23/gitea-release.git",

View file

@ -55,7 +55,7 @@
"auth-header": "^1.0.0",
"commander": "^10.0.0",
"cors": "^2.8.5",
"dblang": "https://jusax.de/git/attachments/1317588b-b3f3-4b95-bdcc-34292a023298",
"dblang": "https://jusax.de/git/attachments/377d0a32-3eca-4a8f-9c3a-f8a045a9c5b1",
"express": "^4.18.2",
"juml": "https://jusax.de/git/attachments/208913c5-2851-4b86-a53d-ca99fed168cc",
"nman": "https://jusax.de/git/attachments/5333948b-fe6b-45d2-9230-ca388f6a89bc",

View file

@ -1,4 +1,4 @@
import { and, eq, insert, remove, select, update } from "dblang";
import { and, coalesce, eq, insert, max, plus, remove, select, update } from "dblang";
import { checkSelfTag } from "../../server/outbagURL.js";
import { Act, Client, STATE } from "../user.js";
import { db, listCategories, listProducts } from "../../sys/db.js";
@ -49,7 +49,6 @@ export const addCategory: Act = {
server: "string",
title: "string-256",
color: "string-32",
weight: "number"
},
func: async (client: Client, data: any, aws: (code: string, data: any) => void) => {
if (!checkSelfTag(data.server)) {
@ -68,11 +67,15 @@ export const addCategory: Act = {
listCategories.title,
listCategories.weight,
listCategories.color
).add(
roomID,
data.title,
data.weight,
data.color
).setSelect(
select([
roomID,
data.title,
plus(coalesce(max(listCategories.weight), 0), 1),
data.color
], listCategories)
.where(eq(listCategories.roomID, roomID))
.limit(1)
).query(db);
if (req.affectedRows > 0) aws("ok", {
catID: req.insertId