File tree Expand file tree Collapse file tree 3 files changed +31
-18
lines changed Expand file tree Collapse file tree 3 files changed +31
-18
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 10
10
"preview" : " NODE_OPTIONS='--import ./public/instrument.server.mjs' nuxt preview" ,
11
11
"postinstall" : " nuxt prepare && prisma generate" ,
12
12
"update-club-info" : " tsx utils/update-club-info.ts" ,
13
- "upload -classroom-info " : " tsx data/ classroom/write .ts" ,
13
+ "update -classroom-data " : " tsx utils/update- classroom-data .ts" ,
14
14
"lint" : " eslint ." ,
15
15
"lint:fix" : " eslint . --fix" ,
16
16
"typecheck" : " vue-tsc --noEmit --skipLibCheck"
Original file line number Diff line number Diff line change
1
+ import { PrismaClient } from '@prisma/client'
2
+ import data from '~/data/classroom/classroom.json'
3
+
4
+ const prisma = new PrismaClient ( )
5
+
6
+ const runSequence : any = [ ]
7
+
8
+ data . forEach ( ( e ) => {
9
+ runSequence . push (
10
+ prisma . classroomData . upsert ( {
11
+ where : {
12
+ name : e . name ,
13
+ } ,
14
+ update : {
15
+ name : e . name ,
16
+ alias : e . alias ,
17
+ size : e . size ,
18
+ } ,
19
+ create : {
20
+ name : e . name ,
21
+ alias : e . alias ,
22
+ size : e . size ,
23
+ } ,
24
+ } ) ,
25
+ )
26
+ } )
27
+
28
+ // eslint-disable-next-line no-console
29
+ console . log ( `start transaction with length ${ runSequence . length } ` )
30
+ await prisma . $transaction ( runSequence )
You can’t perform that action at this time.
0 commit comments