-
-
Notifications
You must be signed in to change notification settings - Fork 814
Expand file tree
/
Copy pathdata.ts
More file actions
50 lines (42 loc) · 1.07 KB
/
data.ts
File metadata and controls
50 lines (42 loc) · 1.07 KB
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
import { faker } from "@faker-js/faker";
export interface IUser {
id: string;
firstName: string;
lastName: string;
}
export interface IPost {
id: string;
authorId: string;
title: string;
content: string;
}
export interface IComment {
id: string;
postId: string;
authorId: string;
comment: string;
}
export const Users = new Map<string, IUser>();
export const Posts = new Map<string, IPost>();
export const Comments = new Map<string, IComment>();
faker.seed(123);
// Create 100 users, posts and comments
for (let i = 1; i <= 100; i += 1) {
Users.set(String(i), {
id: String(i),
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
});
Posts.set(String(i), {
id: String(i),
authorId: String(faker.number.int({ min: 1, max: 100 })),
title: faker.lorem.text(),
content: faker.lorem.paragraphs(2),
});
Comments.set(String(i), {
id: String(i),
authorId: String(faker.number.int({ min: 1, max: 100 })),
postId: String(faker.number.int({ min: 1, max: 100 })),
comment: faker.lorem.text(),
});
}