File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { mockFiles , mockFolders } from "~/lib/mock-data" ;
2+ import { db } from "~/server/db" ;
3+ import { files , folders } from "~/server/db/schema" ;
4+
5+ export default function SandboxPage ( ) {
6+ return (
7+ < div className = "mx-96 flex flex-col gap-4" >
8+ Seed Function
9+ < form
10+ action = { async ( ) => {
11+ "use server" ;
12+
13+ console . log ( "Seeding database..." ) ;
14+
15+ const foldersResult = await db . insert ( folders ) . values (
16+ mockFolders . map ( ( folder , idx ) => ( {
17+ id : idx + 1 ,
18+ name : folder . name ,
19+ parent : idx !== 0 ? 1 : null ,
20+ } ) ) ,
21+ ) ;
22+ const filesResult = await db . insert ( files ) . values (
23+ mockFiles . map ( ( file , idx ) => ( {
24+ id : idx + 1 ,
25+ name : file . name ,
26+ size : 5000 ,
27+ url : file . url ,
28+ parent : ( idx % 3 ) + 1 ,
29+ } ) ) ,
30+ ) ;
31+
32+ console . log ( "Folders inserted:" , foldersResult [ 0 ] . affectedRows ) ;
33+ console . log ( "Files inserted:" , filesResult [ 0 ] . affectedRows ) ;
34+ } }
35+ >
36+ < button type = "submit" > Seed</ button >
37+ </ form >
38+ </ div >
39+ ) ;
40+ }
You can’t perform that action at this time.
0 commit comments