Cleanup video join in entries

This commit is contained in:
Zoe Roux
2025-03-09 01:39:41 +01:00
parent c161d680e3
commit fc60fcc7c4
2 changed files with 23 additions and 10 deletions
+8
View File
@@ -94,10 +94,18 @@ export function values(items: Record<string, unknown>[]) {
};
}
export const coalesce = (val: SQLWrapper, def: SQLWrapper) => {
return sql`coalesce(${val}, ${def})`;
};
export const jsonbObjectAgg = (key: SQLWrapper, value: SQLWrapper) => {
return sql`jsonb_object_agg(${sql.join([key, value], sql.raw(","))})`;
};
export const jsonbAgg = (val: SQLWrapper) => {
return sql`jsonb_agg(${val})`;
};
export const jsonbBuildObject = (select: Record<string, SQLWrapper>) => {
const query = sql.join(
Object.entries(select).flatMap(([k, v]) => {