-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfakerCreate.js
More file actions
35 lines (31 loc) · 994 Bytes
/
fakerCreate.js
File metadata and controls
35 lines (31 loc) · 994 Bytes
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
const faker = require("faker");
const Item = require("./models/item.model");
const Ticket = require("./models/ticket.model");
const statusArray = ["not processed", "in progress", "done"];
const createTicket = async () => {
for (let i = 0; i < 10; i++) {
let item1 = await Item.create({
name: faker.commerce.productName(),
quantity: Math.floor(Math.random() * 10),
});
item1.save();
let item2 = await Item.create({
name: faker.commerce.productName(),
quantity: Math.floor(Math.random() * 10),
});
item2.save();
let item3 = await Item.create({
name: faker.commerce.productName(),
quantity: Math.floor(Math.random() * 10),
});
item1.save();
const fakeTicket = {
address: faker.address.streetAddress(),
items: [item1, item2, item3],
phoneNumber: faker.phone.phoneNumber(),
status: statusArray[Math.floor(Math.random() * 3)],
};
await Ticket.create(fakeTicket);
}
};
createTicket();