-
Notifications
You must be signed in to change notification settings - Fork 0
/
demoUsers.js
66 lines (58 loc) · 1.64 KB
/
demoUsers.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
const User = require("./models/User.model");
const Admin = require("./models/Admin.model");
const demoUsers = async () => {
const user_email = "[email protected]";
const admin_email = "[email protected]";
try {
const demoUserExists = await User.findOne({ user_email });
const demoAdminExists = await Admin.findOne({ admin_email });
if (!demoAdminExists) {
const adminAdmin = await Admin.create({
admin_name: "admin user",
admin_email,
admin_password: "asdfgh123",
admin_phone: 1234567890,
});
const adminUser = await User.create({
user_name: "demo admin",
user_email: admin_email,
user_password: "asdfgh123",
user_phone: 1234567890,
user_address: {
city: "gotham",
street: "imbatman",
building: "13",
apartment: "3",
},
user_orders: [],
user_avatar: "",
admin_id: adminAdmin._id,
});
console.log("demo admin created");
} else {
console.log("demo admin already exists");
}
if (!demoUserExists) {
const regularUser = await User.create({
user_name: "demo user",
user_email,
user_password: "asdfgh123",
user_phone: 1234567890,
user_address: {
city: "metropolis",
street: "main st.",
building: "13",
apartment: "3",
},
user_orders: [],
user_avatar: "",
});
console.log("demo user created");
} else {
console.log("demo user already exists");
}
} catch (error) {
console.log(error);
}
};
module.exports = demoUsers;