fix: resolve TypeScript build errors from leftJoin nullable types
Non-null assert photo/achievement ids that are structurally non-null due to FK constraints but nullable in Drizzle's leftJoin return type. Add missing description field to enrichVideo model select and map. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,7 @@ async function enrichVideo(db: DB, video: typeof videos.$inferSelect) {
|
||||
artist_name: users.artist_name,
|
||||
slug: users.slug,
|
||||
avatar: users.avatar,
|
||||
description: users.description,
|
||||
})
|
||||
.from(video_models)
|
||||
.leftJoin(users, eq(video_models.user_id, users.id))
|
||||
@@ -63,9 +64,19 @@ async function enrichVideo(db: DB, video: typeof videos.$inferSelect) {
|
||||
.from(video_plays)
|
||||
.where(eq(video_plays.video_id, video.id));
|
||||
|
||||
const models = modelRows
|
||||
.filter((m) => m.id !== null)
|
||||
.map((m) => ({
|
||||
id: m.id!,
|
||||
artist_name: m.artist_name,
|
||||
slug: m.slug,
|
||||
avatar: m.avatar,
|
||||
description: m.description,
|
||||
}));
|
||||
|
||||
return {
|
||||
...video,
|
||||
models: modelRows,
|
||||
models,
|
||||
movie_file: movieFile,
|
||||
likes_count: likesCount[0]?.count || 0,
|
||||
plays_count: playsCount[0]?.count || 0,
|
||||
|
||||
Reference in New Issue
Block a user