File tree Expand file tree Collapse file tree 6 files changed +55
-23
lines changed Expand file tree Collapse file tree 6 files changed +55
-23
lines changed Original file line number Diff line number Diff line change 47
47
"typecheck" : " tsc --noEmit"
48
48
},
49
49
"peerDependencies" : {
50
- "@prisma/client" : " ^4.10.1" ,
51
50
"@stacksjs/path" : " workspace:*" ,
52
51
"@stacksjs/utils" : " workspace:*"
53
52
},
54
53
"devDependencies" : {
55
54
"@stacksjs/testing" : " workspace:*" ,
56
55
"mkdist" : " ^1.1.1" ,
57
56
"typescript" : " ^4.9.5"
57
+ },
58
+ "dependencies" : {
59
+ "@prisma/client" : " ^4.10.1"
58
60
}
59
61
}
Original file line number Diff line number Diff line change 1
- // import { PrismaClient } from '@prisma/client'
1
+ import { PrismaClient } from '@prisma/client'
2
2
import type { SeedData } from '@stacksjs/types'
3
3
4
4
async function seed ( modelName : string , data : SeedData [ ] ) : Promise < void > {
5
- // const prisma = new PrismaClient()
5
+ const prisma = new PrismaClient ( )
6
6
7
- // try {
8
- // const model = prisma[modelName]
9
- // const seedPromises = data.map(item => model.create({ data: item }))
10
- // await Promise.all(seedPromises)
11
- // console.log(`Seeding successful for model "${modelName}"`)
12
- // }
13
- // catch (error) {
14
- // console.error(`Error seeding model "${modelName}": ${error.message}`)
15
- // }
16
- // finally {
17
- // await prisma.$disconnect()
18
- // }
7
+ try {
8
+ const model = prisma [ modelName ]
9
+ const seedPromises = data . map ( item => model . create ( { data : item } ) )
10
+ await Promise . all ( seedPromises )
11
+ console . log ( `Seeding successful for model "${ modelName } "` )
12
+ }
13
+ catch ( error ) {
14
+ console . error ( `Error seeding model "${ modelName } ": ${ error . message } ` )
15
+ }
16
+ finally {
17
+ await prisma . $disconnect ( )
18
+ }
19
19
console . log ( 'test' )
20
20
}
21
21
Original file line number Diff line number Diff line change
1
+ datasource db {
2
+ provider = " postgresql "
3
+ url = env (" DATABASE_URL " )
4
+ }
5
+
6
+ generator client {
7
+ provider = " prisma-client-js "
8
+ }
9
+
10
+ model User {
11
+ id Int @id @default (autoincrement () )
12
+ createdAt DateTime @default (now () )
13
+ updatedAt DateTime @updatedAt ()
14
+ name String @unique
15
+ }
16
+
Original file line number Diff line number Diff line change 127
127
" ../**/README.md" ,
128
128
" ../**/dist/**" ,
129
129
" ../**/node_modules/**"
130
- ],
131
- "extends" : " ./api/.nitro/types/tsconfig.json"
130
+ ]
131
+ // "extends": "./api/.nitro/types/tsconfig.json"
132
132
}
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " User" ,
3
+ "fields" : [
4
+ {
5
+ "name" : " name" ,
6
+ "type" : " String" ,
7
+ "unique" : true
8
+ }
9
+ ]
10
+ }
You can’t perform that action at this time.
0 commit comments