-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathseeder.js
More file actions
28 lines (27 loc) · 771 Bytes
/
seeder.js
File metadata and controls
28 lines (27 loc) · 771 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
const db = require("./config/mongoose");
const User = require("./models/user");
User.findOne(
{ email: "admin@gmail.com", role: "admin" },
function (error, user) {
if (error) {
console.log(error);
console.log("Admin could not be created");
return;
}
if (!user) {
User.create({ email: "admin@gmail.com", password:"admin12345", name:"Admin", role: "Admin" }, function (error, user) {
if (error) {
console.log(error);
console.log("Admin could not be created");
return;
} else {
console.log("Admin Created Successfully: admin@gmail.com, pass- admin12345");
return;
}
});
} else {
console.log("Admin Already Exists");
return;
}
}
);