-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.ts
64 lines (57 loc) · 1.66 KB
/
seed.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
import { faker } from '@faker-js/faker/locale/hu';
import { Group, PrismaClient, User } from '@prisma/client';
const prisma = new PrismaClient();
type CreateGroup = Omit<Group, 'createdAt' | 'updatedAt' | 'id' | 'icon' | 'color'>;
async function run() {
const users: Omit<User, 'createdAt' | 'updatedAt' | 'emailVerified' | 'id'>[] = [];
for (let i = 0; i < 50; i++) {
users.push({
address: faker.location.streetAddress(),
isSuperAdmin: false,
nickname: '',
password: faker.internet.password(),
email: faker.internet.email(),
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
phone: faker.phone.number(),
graduationDate: faker.date.recent({ days: 365 }),
});
}
await prisma.user.createMany({ data: users });
const schId = await prisma.group.create({
data: {
name: 'Schönherz Alumni',
description: 'Root group',
},
});
const vikId = await prisma.group.create({
data: {
name: 'BME Villamosmérnöki és Informatikai Kar',
description: 'Root group',
},
});
const groups: CreateGroup[] = [];
for (let i = 0; i < 5; i++) {
groups.push({
name: faker.commerce.department(),
description: faker.lorem.sentence(),
parentGroupId: schId.id,
legacyMaillist: [],
});
groups.push({
name: faker.commerce.department(),
description: faker.lorem.sentence(),
parentGroupId: vikId.id,
legacyMaillist: [],
});
}
await prisma.group.createMany({ data: groups });
}
run()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});