update sql

This commit is contained in:
mertalev
2025-05-05 09:38:24 -04:00
parent b20440e4d5
commit f7712c332e
3 changed files with 90 additions and 50 deletions
+3 -1
View File
@@ -691,7 +691,9 @@ export class AssetRepository {
eb.fn.coalesce(eb.fn('array_agg', ['status']), sql.lit('{}')).as('status'),
eb.fn.coalesce(eb.fn('array_agg', ['thumbhash']), sql.lit('{}')).as('thumbhash'),
])
.$if(!!options.withStacked, (qb) => qb.select((eb) => eb.fn('array_agg', ['stack']).as('stack'))),
.$if(!!options.withStacked, (qb) =>
qb.select((eb) => eb.fn.coalesce(eb.fn('array_agg', ['stack']), sql.lit('{}')).as('stack')),
),
)
.selectFrom('agg')
.select(sql<string>`to_json(agg)::text`.as('assets'));