From a5ee6313d6d7f1908871708c4b8103a4821c1984 Mon Sep 17 00:00:00 2001 From: Flummi Date: Thu, 31 Mar 2022 20:11:22 +0200 Subject: [PATCH] =?UTF-8?q?und=20DAs=20${dB`=20`}=20isT=20unN=C3=96tiG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/inc/routes/apiv2/tags.mjs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/inc/routes/apiv2/tags.mjs b/src/inc/routes/apiv2/tags.mjs index 2b04680..315930e 100644 --- a/src/inc/routes/apiv2/tags.mjs +++ b/src/inc/routes/apiv2/tags.mjs @@ -49,18 +49,19 @@ export default router => { insert into "tags" ${ db({ tag: tagname - }, 'tag') + }) } returning id - `)[0]; + `)[0].id; } + await db` insert into "tags_assign" ${ db({ tag_id: +tagid, item_id: +postid, user_id: +req.session.id - }, 'tag_id', 'item_id', 'user_id') + }) } `; } catch(err) { @@ -98,7 +99,7 @@ export default router => { item_id: +postid, tag_id: 1, user_id: +req.session.id - }, 'item_id', 'tag_id', 'user_id') + }) } `; } @@ -106,7 +107,7 @@ export default router => { // update await db` update "tags_assign" - set tag_id = ${db`(array[2,1])[tag_id]`} + set tag_id = (array[2,1])[tag_id] where tag_id = any(array[1,2]) and item_id = ${+postid} `;