und DAs ${dB } isT unNÖtiG

This commit is contained in:
Flummi 2022-03-31 20:11:22 +02:00
parent 4369aaf1dd
commit a5ee6313d6

View File

@ -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}
`;