add join to images

This commit is contained in:
Zutatensuppe 2021-06-03 23:49:03 +02:00
parent 22585b92fe
commit ef547e9825
2 changed files with 2 additions and 0 deletions

View file

@ -1319,6 +1319,7 @@ const getAllTags = (db) => {
const query = ` const query = `
select c.id, c.slug, c.title, count(*) as total from categories c select c.id, c.slug, c.title, count(*) as total from categories c
inner join image_x_category ixc on c.id = ixc.category_id inner join image_x_category ixc on c.id = ixc.category_id
inner join images i on i.id = ixc.image_id
group by c.id order by total desc;`; group by c.id order by total desc;`;
return db._getMany(query).map(row => ({ return db._getMany(query).map(row => ({
id: parseInt(row.id, 10) || 0, id: parseInt(row.id, 10) || 0,

View file

@ -76,6 +76,7 @@ const getAllTags = (db: Db): Tag[] => {
const query = ` const query = `
select c.id, c.slug, c.title, count(*) as total from categories c select c.id, c.slug, c.title, count(*) as total from categories c
inner join image_x_category ixc on c.id = ixc.category_id inner join image_x_category ixc on c.id = ixc.category_id
inner join images i on i.id = ixc.image_id
group by c.id order by total desc;` group by c.id order by total desc;`
return db._getMany(query).map(row => ({ return db._getMany(query).map(row => ({
id: parseInt(row.id, 10) || 0, id: parseInt(row.id, 10) || 0,