-
Notifications
You must be signed in to change notification settings - Fork 12
/
001_UserSeeder.ts
64 lines (61 loc) · 2.13 KB
/
001_UserSeeder.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 User from "#models/user";
import { BaseSeeder } from "@adonisjs/lucid/seeders";
import { faker } from "@faker-js/faker";
import { RIGHTS, generateRights } from "@galadrim-tools/shared";
export default class UserSeeder extends BaseSeeder {
public static environment = ["development"];
public async run() {
await User.updateOrCreateMany("id", [
{
id: 1,
username: "test",
email: "[email protected]",
imageUrl: "https://forest.galadrim.fr/img/users/default.png",
password: "test",
rights: RIGHTS.DEFAULT,
},
{
id: 2,
username: "miam",
email: "[email protected]",
imageUrl:
"https://static8.depositphotos.com/1010340/945/v/450/depositphotos_9459006-stock-illustration-chef-cartoon.jpg",
password: "miam",
rights: generateRights(["MIAM_ADMIN"]),
},
{
id: 3,
username: "admin",
email: "[email protected]",
imageUrl: "https://forest.galadrim.fr/img/users/105.jpg",
password: "admin",
rights: generateRights([
"EVENT_ADMIN",
"MIAM_ADMIN",
"RIGHTS_ADMIN",
"USER_ADMIN",
"DASHBOARD_ADMIN",
]),
},
{
id: 4,
username: "peon",
email: "[email protected]",
imageUrl: "https://forest.galadrim.fr/img/users/default.png",
password: "peon",
rights: RIGHTS.DEFAULT,
},
]);
const userDtos = [];
for (let i = 1; i <= 100; i++) {
userDtos.push({
username: faker.internet.userName(),
email: faker.internet.email(),
imageUrl: faker.image.url(),
password: "test",
rights: RIGHTS.DEFAULT,
});
}
await User.createMany(userDtos);
}
}