-
Notifications
You must be signed in to change notification settings - Fork 0
/
seed.js
33 lines (30 loc) · 878 Bytes
/
seed.js
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
const { commerce, datatype, image } = require("faker");
const { times } = require("lodash");
const createRange = (min, max) => {
return Math.floor(Math.random() * (max - min + 1) + min);
};
const numberOfItems = createRange(10, 30);
module.exports = function () {
return {
items: times(numberOfItems, function () {
return {
id: datatype.uuid(),
name: commerce.productName(),
description: commerce.productDescription(),
variants: times(createRange(1, 6), function () {
return {
id: datatype.uuid(),
name: commerce.productName(),
description: commerce.productDescription(),
price: commerce.price() * 100,
};
}),
imageUrls: [
{
url: image.imageUrl(350, 350, "technics", true),
},
],
};
}),
};
};