Enable users to edit video titles, descriptions, and thumbnails
Introduce functionality to edit video metadata including title, description, category, tags, and public status, along with a new modal for editing and a backend endpoint for updating video information. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 11420304-80a9-4ef2-adff-cbdaa418ffa8 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/11420304-80a9-4ef2-adff-cbdaa418ffa8/vOcB2tQ
This commit is contained in:
parent
99c55d99df
commit
84c41fe289
252
client/src/components/video-edit-modal.tsx
Normal file
252
client/src/components/video-edit-modal.tsx
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { X, Upload, Save } from "lucide-react";
|
||||||
|
import { type Video, type UpdateVideo, updateVideoSchema } from "@shared/schema";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { apiRequest, queryClient } from "@/lib/queryClient";
|
||||||
|
import { useToast } from "@/hooks/use-toast";
|
||||||
|
import { useMutation } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
interface VideoEditModalProps {
|
||||||
|
video: Video;
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function VideoEditModal({ video, isOpen, onClose }: VideoEditModalProps) {
|
||||||
|
const [title, setTitle] = useState(video.title);
|
||||||
|
const [description, setDescription] = useState(video.description || "");
|
||||||
|
const [category, setCategory] = useState(video.category || "");
|
||||||
|
const [tags, setTags] = useState((video.tags || []).join(", "));
|
||||||
|
const [isPublic, setIsPublic] = useState(video.isPublic);
|
||||||
|
const [customThumbnail, setCustomThumbnail] = useState<File | null>(null);
|
||||||
|
const [thumbnailPreview, setThumbnailPreview] = useState<string | null>(video.customThumbnailUrl);
|
||||||
|
|
||||||
|
const { toast } = useToast();
|
||||||
|
|
||||||
|
const updateVideoMutation = useMutation({
|
||||||
|
mutationFn: async (updates: UpdateVideo) => {
|
||||||
|
return apiRequest(`/api/videos/${video.id}`, {
|
||||||
|
method: "PATCH",
|
||||||
|
body: updates
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast({ title: "Video uspešno posodobljen!" });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["/api/videos"] });
|
||||||
|
onClose();
|
||||||
|
},
|
||||||
|
onError: () => {
|
||||||
|
toast({
|
||||||
|
title: "Napaka pri posodabljanju",
|
||||||
|
description: "Video ni bil posodobljen",
|
||||||
|
variant: "destructive"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleThumbnailChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const file = e.target.files?.[0];
|
||||||
|
if (file) {
|
||||||
|
setCustomThumbnail(file);
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = () => setThumbnailPreview(reader.result as string);
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSave = () => {
|
||||||
|
try {
|
||||||
|
const tagsArray = tags.split(",").map(tag => tag.trim()).filter(tag => tag.length > 0);
|
||||||
|
|
||||||
|
const updates: UpdateVideo = {
|
||||||
|
title: title.trim(),
|
||||||
|
description: description.trim(),
|
||||||
|
category: category.trim(),
|
||||||
|
tags: tagsArray,
|
||||||
|
isPublic
|
||||||
|
};
|
||||||
|
|
||||||
|
// If there's a custom thumbnail, we would need to upload it first
|
||||||
|
// For now, we'll just save the other metadata
|
||||||
|
if (customThumbnail) {
|
||||||
|
// TODO: Implement thumbnail upload to Bunny.net or storage service
|
||||||
|
toast({
|
||||||
|
title: "Obvestilo",
|
||||||
|
description: "Nalaganje slik bo dodano v prihodnji različici"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateVideoMutation.mutate(updates);
|
||||||
|
} catch (error) {
|
||||||
|
toast({
|
||||||
|
title: "Napaka",
|
||||||
|
description: "Preverite vnesene podatke",
|
||||||
|
variant: "destructive"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!isOpen) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
|
||||||
|
<div className="bg-white dark:bg-gray-900 rounded-lg max-w-2xl w-full max-h-[90vh] overflow-y-auto">
|
||||||
|
<div className="p-6">
|
||||||
|
{/* Header */}
|
||||||
|
<div className="flex items-center justify-between mb-6">
|
||||||
|
<h2 className="text-2xl font-bold text-gray-900 dark:text-white">
|
||||||
|
Uredi video
|
||||||
|
</h2>
|
||||||
|
<Button
|
||||||
|
onClick={onClose}
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
className="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"
|
||||||
|
data-testid="button-close-edit"
|
||||||
|
>
|
||||||
|
<X className="w-5 h-5" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Form */}
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* Title */}
|
||||||
|
<div>
|
||||||
|
<Label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
||||||
|
Naslov
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
value={title}
|
||||||
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
|
placeholder="Vnesite naslov videoposnetka"
|
||||||
|
className="w-full"
|
||||||
|
data-testid="input-video-title"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Description */}
|
||||||
|
<div>
|
||||||
|
<Label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
||||||
|
Opis
|
||||||
|
</Label>
|
||||||
|
<Textarea
|
||||||
|
value={description}
|
||||||
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
|
placeholder="Opišite vsebino videoposnetka"
|
||||||
|
rows={4}
|
||||||
|
className="w-full"
|
||||||
|
data-testid="input-video-description"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Category */}
|
||||||
|
<div>
|
||||||
|
<Label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
||||||
|
Kategorija
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
value={category}
|
||||||
|
onChange={(e) => setCategory(e.target.value)}
|
||||||
|
placeholder="npr. Izobraževanje, Zabava, Tehnologija"
|
||||||
|
className="w-full"
|
||||||
|
data-testid="input-video-category"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Tags */}
|
||||||
|
<div>
|
||||||
|
<Label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
||||||
|
Oznake (ločene z vejico)
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
value={tags}
|
||||||
|
onChange={(e) => setTags(e.target.value)}
|
||||||
|
placeholder="npr. tutorial, spletno programiranje, react"
|
||||||
|
className="w-full"
|
||||||
|
data-testid="input-video-tags"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Thumbnail Upload */}
|
||||||
|
<div>
|
||||||
|
<Label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
||||||
|
Slika predogleda
|
||||||
|
</Label>
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
{thumbnailPreview && (
|
||||||
|
<div className="w-32 h-18 rounded overflow-hidden">
|
||||||
|
<img
|
||||||
|
src={thumbnailPreview}
|
||||||
|
alt="Predogled"
|
||||||
|
className="w-full h-full object-cover"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<Label className="cursor-pointer">
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
accept="image/*"
|
||||||
|
onChange={handleThumbnailChange}
|
||||||
|
className="hidden"
|
||||||
|
data-testid="input-thumbnail-upload"
|
||||||
|
/>
|
||||||
|
<div className="flex items-center gap-2 px-4 py-2 bg-gray-100 dark:bg-gray-700 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors">
|
||||||
|
<Upload className="w-4 h-4" />
|
||||||
|
<span className="text-sm">Naloži sliko</span>
|
||||||
|
</div>
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Privacy */}
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="public-video"
|
||||||
|
checked={isPublic}
|
||||||
|
onChange={(e) => setIsPublic(e.target.checked)}
|
||||||
|
className="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500"
|
||||||
|
data-testid="checkbox-public-video"
|
||||||
|
/>
|
||||||
|
<Label htmlFor="public-video" className="text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
Javno dostopen video
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Footer */}
|
||||||
|
<div className="flex justify-end gap-3 mt-8 pt-6 border-t border-gray-200 dark:border-gray-700">
|
||||||
|
<Button
|
||||||
|
onClick={onClose}
|
||||||
|
variant="outline"
|
||||||
|
data-testid="button-cancel-edit"
|
||||||
|
>
|
||||||
|
Prekliči
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={handleSave}
|
||||||
|
disabled={updateVideoMutation.isPending || !title.trim()}
|
||||||
|
className="bg-blue-600 hover:bg-blue-700"
|
||||||
|
data-testid="button-save-video"
|
||||||
|
>
|
||||||
|
{updateVideoMutation.isPending ? (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<div className="w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin" />
|
||||||
|
Shranjujem...
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Save className="w-4 h-4" />
|
||||||
|
Shrani
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { X, Share2 } from "lucide-react";
|
import { X, Share2, Edit3 } from "lucide-react";
|
||||||
import { type Video } from "@shared/schema";
|
import { type Video } from "@shared/schema";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { apiRequest } from "@/lib/queryClient";
|
import { apiRequest } from "@/lib/queryClient";
|
||||||
@ -9,6 +9,7 @@ import {
|
|||||||
TwitterIcon,
|
TwitterIcon,
|
||||||
WhatsappIcon
|
WhatsappIcon
|
||||||
} from "react-share";
|
} from "react-share";
|
||||||
|
import VideoEditModal from "./video-edit-modal";
|
||||||
|
|
||||||
// HLS.js types for video streaming
|
// HLS.js types for video streaming
|
||||||
|
|
||||||
@ -55,6 +56,7 @@ export default function VideoModal({ video, isOpen, onClose }: VideoModalProps)
|
|||||||
const videoRef = useRef<HTMLVideoElement>(null);
|
const videoRef = useRef<HTMLVideoElement>(null);
|
||||||
const hlsRef = useRef<Hls | null>(null);
|
const hlsRef = useRef<Hls | null>(null);
|
||||||
const [showShareMenu, setShowShareMenu] = useState(false);
|
const [showShareMenu, setShowShareMenu] = useState(false);
|
||||||
|
const [showEditModal, setShowEditModal] = useState(false);
|
||||||
const [videoThumbnail, setVideoThumbnail] = useState<string | null>(null);
|
const [videoThumbnail, setVideoThumbnail] = useState<string | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -274,6 +276,16 @@ export default function VideoModal({ video, isOpen, onClose }: VideoModalProps)
|
|||||||
|
|
||||||
{/* Video Controls and Share Menu */}
|
{/* Video Controls and Share Menu */}
|
||||||
<div className="absolute top-4 right-4 flex gap-2">
|
<div className="absolute top-4 right-4 flex gap-2">
|
||||||
|
{/* Edit Button */}
|
||||||
|
<Button
|
||||||
|
onClick={() => setShowEditModal(true)}
|
||||||
|
variant="secondary"
|
||||||
|
size="sm"
|
||||||
|
data-testid="button-edit-video"
|
||||||
|
>
|
||||||
|
<Edit3 className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
{/* Share Button */}
|
{/* Share Button */}
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<Button
|
<Button
|
||||||
@ -388,6 +400,15 @@ export default function VideoModal({ video, isOpen, onClose }: VideoModalProps)
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Video Edit Modal */}
|
||||||
|
{video && (
|
||||||
|
<VideoEditModal
|
||||||
|
video={video}
|
||||||
|
isOpen={showEditModal}
|
||||||
|
onClose={() => setShowEditModal(false)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import type { Express } from "express";
|
|||||||
import { createServer, type Server } from "http";
|
import { createServer, type Server } from "http";
|
||||||
import { storage } from "./storage";
|
import { storage } from "./storage";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
import { updateVideoSchema } from "@shared/schema";
|
||||||
|
|
||||||
export async function registerRoutes(app: Express): Promise<Server> {
|
export async function registerRoutes(app: Express): Promise<Server> {
|
||||||
// Get videos with pagination and filtering
|
// Get videos with pagination and filtering
|
||||||
@ -47,6 +48,25 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Update video metadata (title, description, etc.)
|
||||||
|
app.patch("/api/videos/:id", async (req, res) => {
|
||||||
|
try {
|
||||||
|
const updates = updateVideoSchema.parse(req.body);
|
||||||
|
const updatedVideo = await storage.updateVideo(req.params.id, updates);
|
||||||
|
|
||||||
|
if (!updatedVideo) {
|
||||||
|
return res.status(404).json({ message: "Video not found" });
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json(updatedVideo);
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof z.ZodError) {
|
||||||
|
return res.status(400).json({ message: "Invalid request data", errors: error.errors });
|
||||||
|
}
|
||||||
|
res.status(500).json({ message: "Failed to update video" });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { type Video, type InsertVideo } from "@shared/schema";
|
import { type Video, type InsertVideo, type UpdateVideo } from "@shared/schema";
|
||||||
import { randomUUID } from "crypto";
|
import { randomUUID } from "crypto";
|
||||||
import { BunnyService } from "./bunny";
|
import { BunnyService } from "./bunny";
|
||||||
|
|
||||||
@ -6,6 +6,7 @@ export interface IStorage {
|
|||||||
getVideos(limit?: number, offset?: number, search?: string): Promise<Video[]>;
|
getVideos(limit?: number, offset?: number, search?: string): Promise<Video[]>;
|
||||||
getVideo(id: string): Promise<Video | undefined>;
|
getVideo(id: string): Promise<Video | undefined>;
|
||||||
createVideo(video: InsertVideo): Promise<Video>;
|
createVideo(video: InsertVideo): Promise<Video>;
|
||||||
|
updateVideo(id: string, video: UpdateVideo): Promise<Video | undefined>;
|
||||||
updateVideoViews(id: string): Promise<void>;
|
updateVideoViews(id: string): Promise<void>;
|
||||||
getVideoCount(search?: string): Promise<number>;
|
getVideoCount(search?: string): Promise<number>;
|
||||||
}
|
}
|
||||||
@ -83,10 +84,15 @@ export class MemStorage implements IStorage {
|
|||||||
const fullVideo: Video = {
|
const fullVideo: Video = {
|
||||||
...video,
|
...video,
|
||||||
id,
|
id,
|
||||||
views: video.views || 0,
|
description: video.description || "",
|
||||||
description: video.description || null,
|
category: video.category || "",
|
||||||
category: video.category || null,
|
customThumbnailUrl: null,
|
||||||
createdAt: new Date()
|
videoUrlMp4: null,
|
||||||
|
videoUrlIframe: null,
|
||||||
|
tags: [],
|
||||||
|
isPublic: true,
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date()
|
||||||
};
|
};
|
||||||
this.videos.set(id, fullVideo);
|
this.videos.set(id, fullVideo);
|
||||||
});
|
});
|
||||||
@ -119,15 +125,33 @@ export class MemStorage implements IStorage {
|
|||||||
const fullVideo: Video = {
|
const fullVideo: Video = {
|
||||||
...video,
|
...video,
|
||||||
id,
|
id,
|
||||||
views: video.views || 0,
|
description: video.description || "",
|
||||||
description: video.description || null,
|
category: video.category || "",
|
||||||
category: video.category || null,
|
customThumbnailUrl: null,
|
||||||
createdAt: new Date()
|
videoUrlMp4: null,
|
||||||
|
videoUrlIframe: null,
|
||||||
|
tags: video.tags || [],
|
||||||
|
isPublic: video.isPublic ?? true,
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date()
|
||||||
};
|
};
|
||||||
this.videos.set(id, fullVideo);
|
this.videos.set(id, fullVideo);
|
||||||
return fullVideo;
|
return fullVideo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateVideo(id: string, updates: UpdateVideo): Promise<Video | undefined> {
|
||||||
|
const video = this.videos.get(id);
|
||||||
|
if (!video) return undefined;
|
||||||
|
|
||||||
|
const updatedVideo: Video = {
|
||||||
|
...video,
|
||||||
|
...updates,
|
||||||
|
updatedAt: new Date()
|
||||||
|
};
|
||||||
|
this.videos.set(id, updatedVideo);
|
||||||
|
return updatedVideo;
|
||||||
|
}
|
||||||
|
|
||||||
async updateVideoViews(id: string): Promise<void> {
|
async updateVideoViews(id: string): Promise<void> {
|
||||||
const video = this.videos.get(id);
|
const video = this.videos.get(id);
|
||||||
if (video) {
|
if (video) {
|
||||||
@ -212,6 +236,12 @@ class BunnyStorage implements IStorage {
|
|||||||
throw new Error("Creating videos is not supported with Bunny.net integration");
|
throw new Error("Creating videos is not supported with Bunny.net integration");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateVideo(id: string, updates: UpdateVideo): Promise<Video | undefined> {
|
||||||
|
// Note: Updating video metadata in Bunny.net would require API calls
|
||||||
|
// For now, we'll throw an error as this operation is not supported
|
||||||
|
throw new Error("Updating videos is not supported with Bunny.net integration");
|
||||||
|
}
|
||||||
|
|
||||||
async updateVideoViews(id: string): Promise<void> {
|
async updateVideoViews(id: string): Promise<void> {
|
||||||
// Since we can't update views in Bunny.net directly, we'll cache them locally
|
// Since we can't update views in Bunny.net directly, we'll cache them locally
|
||||||
const currentViews = this.viewsCache.get(id) || 0;
|
const currentViews = this.viewsCache.get(id) || 0;
|
||||||
|
|||||||
@ -1,26 +1,38 @@
|
|||||||
import { sql } from "drizzle-orm";
|
import { sql } from "drizzle-orm";
|
||||||
import { pgTable, text, varchar, integer, timestamp } from "drizzle-orm/pg-core";
|
import { pgTable, text, varchar, integer, timestamp, boolean } from "drizzle-orm/pg-core";
|
||||||
import { createInsertSchema } from "drizzle-zod";
|
import { createInsertSchema } from "drizzle-zod";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
export const videos = pgTable("videos", {
|
export const videos = pgTable("videos", {
|
||||||
id: varchar("id").primaryKey(),
|
id: varchar("id").primaryKey(),
|
||||||
title: text("title").notNull(),
|
title: text("title").notNull(),
|
||||||
description: text("description"),
|
description: text("description").default("").notNull(),
|
||||||
thumbnailUrl: text("thumbnail_url").notNull(),
|
thumbnailUrl: text("thumbnail_url").notNull(),
|
||||||
|
customThumbnailUrl: text("custom_thumbnail_url"),
|
||||||
videoUrl: text("video_url").notNull(),
|
videoUrl: text("video_url").notNull(),
|
||||||
videoUrlMp4: text("video_url_mp4"),
|
videoUrlMp4: text("video_url_mp4"),
|
||||||
videoUrlIframe: text("video_url_iframe"),
|
videoUrlIframe: text("video_url_iframe"),
|
||||||
duration: integer("duration").notNull(), // in seconds
|
duration: integer("duration").notNull(), // in seconds
|
||||||
views: integer("views").notNull().default(0),
|
views: integer("views").notNull().default(0),
|
||||||
category: text("category"),
|
category: text("category").default("").notNull(),
|
||||||
|
tags: text("tags").array().default([]).notNull(),
|
||||||
|
isPublic: boolean("is_public").default(true).notNull(),
|
||||||
createdAt: timestamp("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
createdAt: timestamp("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
||||||
|
updatedAt: timestamp("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const insertVideoSchema = createInsertSchema(videos).omit({
|
export const insertVideoSchema = createInsertSchema(videos).omit({
|
||||||
id: true,
|
id: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const updateVideoSchema = createInsertSchema(videos).omit({
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
}).partial();
|
||||||
|
|
||||||
export type InsertVideo = z.infer<typeof insertVideoSchema>;
|
export type InsertVideo = z.infer<typeof insertVideoSchema>;
|
||||||
|
export type UpdateVideo = z.infer<typeof updateVideoSchema>;
|
||||||
export type Video = typeof videos.$inferSelect;
|
export type Video = typeof videos.$inferSelect;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user