Fix entries's video retrieval

This commit is contained in:
Zoe Roux
2025-03-09 16:50:20 +01:00
parent d61573668b
commit 34926dab51
2 changed files with 9 additions and 3 deletions
+8 -2
View File
@@ -41,6 +41,7 @@ import {
sortToSql,
} from "~/models/utils";
import { desc } from "~/models/utils/descriptions";
import type { EmbeddedVideo } from "~/models/video";
const entryFilters: FilterDef = {
kind: {
@@ -115,9 +116,14 @@ async function getEntries({
const videosQ = db
.select({
videos: coalesce(
jsonbAgg(jsonbBuildObject({ slug: entryVideoJoin.slug, ...videosCol })),
jsonbAgg(
jsonbBuildObject<EmbeddedVideo>({
slug: entryVideoJoin.slug,
...videosCol,
}),
),
sql`'[]'::jsonb`,
),
).as("videos"),
})
.from(entryVideoJoin)
.where(eq(entryVideoJoin.entryPk, entries.pk))