default weight
This commit is contained in:
parent
e0011ae7ca
commit
e45be71606
3 changed files with 14 additions and 11 deletions
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -12,7 +12,7 @@
|
||||||
"auth-header": "^1.0.0",
|
"auth-header": "^1.0.0",
|
||||||
"commander": "^10.0.0",
|
"commander": "^10.0.0",
|
||||||
"cors": "^2.8.5",
|
"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",
|
"express": "^4.18.2",
|
||||||
"juml": "https://jusax.de/git/attachments/208913c5-2851-4b86-a53d-ca99fed168cc",
|
"juml": "https://jusax.de/git/attachments/208913c5-2851-4b86-a53d-ca99fed168cc",
|
||||||
"nman": "https://jusax.de/git/attachments/5333948b-fe6b-45d2-9230-ca388f6a89bc",
|
"nman": "https://jusax.de/git/attachments/5333948b-fe6b-45d2-9230-ca388f6a89bc",
|
||||||
|
@ -1108,8 +1108,8 @@
|
||||||
},
|
},
|
||||||
"node_modules/dblang": {
|
"node_modules/dblang": {
|
||||||
"version": "0.9.3",
|
"version": "0.9.3",
|
||||||
"resolved": "https://jusax.de/git/attachments/1317588b-b3f3-4b95-bdcc-34292a023298",
|
"resolved": "https://jusax.de/git/attachments/377d0a32-3eca-4a8f-9c3a-f8a045a9c5b1",
|
||||||
"integrity": "sha512-l2LKpxM79S2UjVWS1W9flLt6uZcVsG2qrc6JwqoFv0rgxMOBzoJnnWaHSD5UJKydgXjMycZIvXpGzkuX6vNfwA==",
|
"integrity": "sha512-Co3RZ2Dfk2Atm2Oyr7rtHJDeiMZ8NwfrvTBwfhP9wVkXQuN1WrMMQ5W+/Ho2g6c6BWbUnsqADKTaCcJZrYBbjQ==",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"gitea-release": "git+https://jusax.de/git/jusax23/gitea-release.git",
|
"gitea-release": "git+https://jusax.de/git/jusax23/gitea-release.git",
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
"auth-header": "^1.0.0",
|
"auth-header": "^1.0.0",
|
||||||
"commander": "^10.0.0",
|
"commander": "^10.0.0",
|
||||||
"cors": "^2.8.5",
|
"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",
|
"express": "^4.18.2",
|
||||||
"juml": "https://jusax.de/git/attachments/208913c5-2851-4b86-a53d-ca99fed168cc",
|
"juml": "https://jusax.de/git/attachments/208913c5-2851-4b86-a53d-ca99fed168cc",
|
||||||
"nman": "https://jusax.de/git/attachments/5333948b-fe6b-45d2-9230-ca388f6a89bc",
|
"nman": "https://jusax.de/git/attachments/5333948b-fe6b-45d2-9230-ca388f6a89bc",
|
||||||
|
|
|
@ -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 { checkSelfTag } from "../../server/outbagURL.js";
|
||||||
import { Act, Client, STATE } from "../user.js";
|
import { Act, Client, STATE } from "../user.js";
|
||||||
import { db, listCategories, listProducts } from "../../sys/db.js";
|
import { db, listCategories, listProducts } from "../../sys/db.js";
|
||||||
|
@ -49,7 +49,6 @@ export const addCategory: Act = {
|
||||||
server: "string",
|
server: "string",
|
||||||
title: "string-256",
|
title: "string-256",
|
||||||
color: "string-32",
|
color: "string-32",
|
||||||
weight: "number"
|
|
||||||
},
|
},
|
||||||
func: async (client: Client, data: any, aws: (code: string, data: any) => void) => {
|
func: async (client: Client, data: any, aws: (code: string, data: any) => void) => {
|
||||||
if (!checkSelfTag(data.server)) {
|
if (!checkSelfTag(data.server)) {
|
||||||
|
@ -68,11 +67,15 @@ export const addCategory: Act = {
|
||||||
listCategories.title,
|
listCategories.title,
|
||||||
listCategories.weight,
|
listCategories.weight,
|
||||||
listCategories.color
|
listCategories.color
|
||||||
).add(
|
).setSelect(
|
||||||
|
select([
|
||||||
roomID,
|
roomID,
|
||||||
data.title,
|
data.title,
|
||||||
data.weight,
|
plus(coalesce(max(listCategories.weight), 0), 1),
|
||||||
data.color
|
data.color
|
||||||
|
], listCategories)
|
||||||
|
.where(eq(listCategories.roomID, roomID))
|
||||||
|
.limit(1)
|
||||||
).query(db);
|
).query(db);
|
||||||
if (req.affectedRows > 0) aws("ok", {
|
if (req.affectedRows > 0) aws("ok", {
|
||||||
catID: req.insertId
|
catID: req.insertId
|
||||||
|
|
Loading…
Reference in a new issue