Skip to content
Snippets Groups Projects

Implement Mongo Seeder v2

Merged D'Abrantes, Felipe (UG - Comp Sci & Elec Eng) requested to merge mongo-seeder-v2 into main
1 file
+ 17
11
Compare changes
  • Side-by-side
  • Inline
@@ -28,18 +28,24 @@ connect().then(async () => {
try {
// Database Seeding
if (process.env.ENABLE_USER_DB_SEEDING) {
const hashedPassword = await bcrypt.hash("password", 10);
try {
const hashedPassword = await bcrypt.hash("password", 10);
const admin = new UserModel({
username: "admin",
password: hashedPassword,
email: "admin@email.com",
profile: "",
admin: true
})
admin.save()
console.log("Successfully seeded User Database!")
const admin = new UserModel({
username: "admin",
password: hashedPassword,
email: "admin@email.com",
profile: "",
admin: true
})
await admin.save()
console.log("Successfully seeded User Database!")
}
catch(error) {
console.log("Error seeding User Database...")
console.log(error)
}
}
app.listen(port, () => {
Loading