Enhance video storage with additional metadata and robust error handling
Update DatabaseStorage to cast query results and use nullish coalescing for rowCount. Add new fields to MemStorage for video details (views, uploadStatus, file details), user profiles (name, image), upload progress, and category attributes. Replit-Commit-Author: Agent Replit-Commit-Session-Id: d7424866-83d1-4486-a212-ac12b4c7becf Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/d7424866-83d1-4486-a212-ac12b4c7becf/Pb94kjC
This commit is contained in:
parent
db5a31e7c1
commit
27358b647a
@ -62,7 +62,7 @@ export class DatabaseStorage implements IStorage {
|
||||
like(videos.title, searchTerm),
|
||||
like(videos.description, searchTerm)
|
||||
)
|
||||
);
|
||||
) as any;
|
||||
}
|
||||
|
||||
const result = await query
|
||||
@ -110,7 +110,7 @@ export class DatabaseStorage implements IStorage {
|
||||
like(videos.title, searchTerm),
|
||||
like(videos.description, searchTerm)
|
||||
)
|
||||
);
|
||||
) as any;
|
||||
}
|
||||
|
||||
const result = await query;
|
||||
@ -119,7 +119,7 @@ export class DatabaseStorage implements IStorage {
|
||||
|
||||
async deleteVideo(id: string): Promise<boolean> {
|
||||
const result = await db.delete(videos).where(eq(videos.id, id));
|
||||
return result.rowCount > 0;
|
||||
return (result.rowCount ?? 0) > 0;
|
||||
}
|
||||
|
||||
// User operations
|
||||
@ -221,7 +221,7 @@ export class DatabaseStorage implements IStorage {
|
||||
|
||||
async deleteCategory(id: string): Promise<boolean> {
|
||||
const result = await db.delete(categories).where(eq(categories.id, id));
|
||||
return result.rowCount > 0;
|
||||
return (result.rowCount ?? 0) > 0;
|
||||
}
|
||||
|
||||
// Tag operations
|
||||
@ -365,8 +365,16 @@ export class MemStorage implements IStorage {
|
||||
videoUrlIframe: null,
|
||||
tags: [],
|
||||
isPublic: true,
|
||||
views: video.views || 0,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date()
|
||||
updatedAt: new Date(),
|
||||
uploadStatus: video.uploadStatus || "completed",
|
||||
originalFileName: video.originalFileName || null,
|
||||
fileSize: video.fileSize || null,
|
||||
bitrate: video.bitrate || null,
|
||||
resolution: video.resolution || null,
|
||||
format: video.format || null,
|
||||
encoding: video.encoding || null
|
||||
};
|
||||
this.videos.set(id, fullVideo);
|
||||
});
|
||||
@ -406,6 +414,14 @@ export class MemStorage implements IStorage {
|
||||
videoUrlIframe: null,
|
||||
tags: video.tags || [],
|
||||
isPublic: video.isPublic ?? true,
|
||||
views: video.views || 0,
|
||||
uploadStatus: video.uploadStatus || "completed",
|
||||
originalFileName: video.originalFileName || null,
|
||||
fileSize: video.fileSize || null,
|
||||
bitrate: video.bitrate || null,
|
||||
resolution: video.resolution || null,
|
||||
format: video.format || null,
|
||||
encoding: video.encoding || null,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date()
|
||||
};
|
||||
@ -464,6 +480,9 @@ export class MemStorage implements IStorage {
|
||||
...user,
|
||||
id,
|
||||
password: hashedPassword,
|
||||
firstName: user.firstName || null,
|
||||
lastName: user.lastName || null,
|
||||
profileImageUrl: user.profileImageUrl || null,
|
||||
isAdmin: user.isAdmin ?? false,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date()
|
||||
@ -503,6 +522,11 @@ export class MemStorage implements IStorage {
|
||||
const fullUpload: VideoUpload = {
|
||||
...upload,
|
||||
id,
|
||||
uploadStatus: upload.uploadStatus || "uploading",
|
||||
uploadProgress: upload.uploadProgress || 0,
|
||||
videoId: upload.videoId || null,
|
||||
errorMessage: upload.errorMessage || null,
|
||||
uploadUrl: upload.uploadUrl || null,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date()
|
||||
};
|
||||
@ -544,6 +568,8 @@ export class MemStorage implements IStorage {
|
||||
const fullCategory: Category = {
|
||||
...category,
|
||||
id,
|
||||
description: category.description || null,
|
||||
color: category.color || "#000000",
|
||||
createdAt: new Date()
|
||||
};
|
||||
this.categoriesMap.set(id, fullCategory);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user