-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.ts
75 lines (64 loc) · 1.7 KB
/
script.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { PrismaClient } from '@prisma/client';
async function main() {
const prisma = new PrismaClient();
const club = await prisma.club.findUnique({
where: { name: 'Salim Cricket Academy' },
});
if (!club) {
return console.log('No Slub Found');
}
const imran = await prisma.player.findUnique({
where: { email: 'imransheikhsadi@gmail.com' },
});
const dipu = await prisma.player.findUnique({
where: { email: 'dipuudayput@gmail.com' },
});
const billal = await prisma.player.findUnique({
where: { email: 'billalislam@gmail.com' },
});
const munna = await prisma.player.findUnique({
where: { email: 'munnasheikh@gmail.com' },
});
if (!imran || !dipu || !billal || !munna) {
return console.log('Not all Players found');
}
const match = await prisma.match.create({
data: {
clubId: club.id,
},
});
const temaOne = await prisma.team.create({
data: {
clubId: club.id,
players: { connect: [{ id: imran.id }, { id: dipu.id }] },
matches: { connect: [{ id: match.id }] },
},
});
const teamTwo = await prisma.team.create({
data: {
clubId: club.id,
players: { connect: [{ id: billal.id }, { id: munna.id }] },
matches: { connect: [{ id: match.id }] },
},
});
const firstInnings = await prisma.innings.create({
data: {
matchId: match.id,
inningsType: 'FIRST',
},
});
const fristBallByImran = await prisma.ball.create({
data: {
bowledTime: new Date(),
ballType: 'LEGAL',
batterId: munna.id,
bowlerId: imran.id,
inningsId: firstInnings.id,
dismissalType: 'NONE',
scoreType: 'REGULAR',
runs: 4,
extra: 0,
},
});
}
main();