File tree Expand file tree Collapse file tree 2 files changed +37
-6
lines changed
apps/web/app/[lang]/(public-fullwidth)/author/[authorId]
packages/database/prisma/seeds Expand file tree Collapse file tree 2 files changed +37
-6
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,8 @@ export const metadata = {
1414
1515export default async function Page ( { params, searchParams } ) {
1616 const { data, total } = await getPosts ( {
17- searchParams : {
18- authorId : params ?. authorId ,
19- ...searchParams ,
20- } ,
17+ authorId : params ?. authorId ,
18+ ...searchParams ,
2119 } )
2220
2321 return (
Original file line number Diff line number Diff line change 11import { PrismaClient } from "@prisma/client"
2+ import posts from "./posts.json" assert { type : "json " }
3+ import slugify from "slugify"
24
35const prisma = new PrismaClient ( )
46
@@ -15,9 +17,40 @@ async function main() {
1517 update : { } ,
1618 } )
1719
18- console . log ( "seed-user:" , { user } )
20+ for ( const post of posts ) {
21+ await prisma . post . create ( {
22+ data : {
23+ title : post . title || '' ,
24+ content : post . description ,
25+ slug : slugify ( post . title || '-' ) + new Date ( ) . getTime ( ) ,
26+ author : {
27+ connect : {
28+ id : user . id ,
29+ } ,
30+ } ,
31+ image : {
32+ create : {
33+ url : post . image_url || '' ,
34+ path : post . image_url || '' ,
35+ name : post . title || '' ,
36+ mime : "" ,
37+ hash : "" ,
38+ ext : "" ,
39+ width : 0 ,
40+ height : 0 ,
41+ format : "" ,
42+ user : {
43+ connect : {
44+ id : user . id ,
45+ }
46+ }
47+ } ,
48+ } ,
49+ } ,
50+ } )
51+ }
1952}
2053
2154main ( ) . then ( ( ) => {
22- console . log ( "User created successfully " )
55+ console . log ( "Seed has been created " )
2356} )
You can’t perform that action at this time.
0 commit comments