1 | const faker = require("faker");
|
2 | const _ = require("lodash");
|
3 | const moment = require("moment");
|
4 |
|
5 | const now = moment();
|
6 |
|
7 | const generate = count =>
|
8 | _.range(count).map((val, index) => {
|
9 | const birthAt = faker.date.between(
|
10 | moment()
|
11 | .subtract(10, "year")
|
12 | .toDate(),
|
13 | moment()
|
14 | .subtract(1, "year")
|
15 | .toDate()
|
16 | );
|
17 |
|
18 | const age = now.diff(moment(birthAt), "year");
|
19 |
|
20 | return {
|
21 | id: faker.random.uuid(),
|
22 | name: faker.name.lastName(),
|
23 | tag: faker.random.arrayElement(["CAT", "DOG"]),
|
24 | owner: faker.name.firstName(),
|
25 | grade: faker.random.number({ min: 1, max: 5 }),
|
26 | age,
|
27 | birthAt: birthAt.toISOString(),
|
28 | };
|
29 | });
|
30 |
|
31 | module.exports = generate;
|