-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.js
105 lines (100 loc) · 2.18 KB
/
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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const { Watch, User } = require("./models");
const bcrypt = require("bcrypt");
// const pw = bcrypt.hashSync("1234", bcrypt.genSaltSync(10), null);
async function createWatches() {
await Watch.destroy({ where: {} });
try {
const watches = await Watch.bulkCreate([
{
name: "Vesper",
description: "fancy watch",
price: 499.0,
brand: "Cartier",
gender: "Unisex"
},
{
name: "Kensington",
description: "fancy watch",
price: 399.0,
brand: "Omega",
gender: "Male"
},
{
name: "Arrow",
description: "fancy watch",
price: 199.0,
brand: "Rolex",
gender: "Female"
},
{
name: "Porter",
description: "fancy watch",
price: 499.0,
brand: "Tag Heuer",
gender: "Female"
},
{
name: "Gatsby",
description: "fancy watch",
price: 299.0,
brand: "Rolex",
gender: "Unisex"
},
{
name: "Eleanor",
description: "fancy watch",
price: 699.0,
brand: "Cartier",
gender: "Female"
},
{
name: "Fancy",
description: "fancy watch",
price: 699.0,
brand: "Cartier",
gender: "Female"
}
]);
} catch (e) {
console.log(e);
}
}
async function createUsers() {
await User.destroy({ where: {} });
try {
const users = await User.bulkCreate([
{
username: "tara",
password: bcrypt.hashSync("tara", bcrypt.genSaltSync(10), null),
admin: true
},
{
username: "john",
password: bcrypt.hashSync("john", bcrypt.genSaltSync(10), null),
admin: true
},
{
username: "test",
password: bcrypt.hashSync("test", bcrypt.genSaltSync(10), null),
admin: true
},
{
username: "user",
password: bcrypt.hashSync("test", bcrypt.genSaltSync(10), null)
}
]);
} catch (e) {
console.log(e);
}
}
async function seed() {
try {
await createWatches();
await createUsers();
} catch (e) {
console.log(e);
} finally {
process.exit();
}
}
seed();