migration to postgresql

This commit is contained in:
Flummi
2022-01-02 06:52:47 +01:00
parent e1bc2c269a
commit e8ff4396aa
11 changed files with 571 additions and 280 deletions

View File

@@ -107,9 +107,10 @@ export default (router, tpl) => {
let tagid;
const tag_exists = await sql("tags").select("id", "tag").where("tag", tag);
if(tag_exists.length === 0) { // create new tag
tagid = (await sql("tags").insert({
await sql("tags").insert({
tag: tag
}))[0];
});
tagid = (await sql("tags").select("id").where("tag", tag))[0].id;
}
else {
tagid = tag_exists[0].id;
@@ -207,7 +208,11 @@ export default (router, tpl) => {
});
}
favs = await sql('favorites').select('user_id').where('item_id', itemid);
favs = await sql('favorites')
.select('user.user', 'user_options.avatar')
.leftJoin('user', 'user.id', 'favorites.user_id')
.leftJoin('user_options', 'user_options.user_id', 'favorites.user_id')
.where('favorites.item_id', itemid);
res.reply({ body: JSON.stringify({
success: true,