Skip to content

Commit

Permalink
Merge pull request #59 from BUMETCS673/add_team_members_to_initdb
Browse files Browse the repository at this point in the history
add all team members into initdb file
  • Loading branch information
eddie27lee authored Oct 6, 2024
2 parents 1d08e17 + a853408 commit 480ef43
Showing 1 changed file with 44 additions and 13 deletions.
57 changes: 44 additions & 13 deletions code/server/initdb.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This file is for initializing data to the MongoDB database

const bcrypt = require('bcrypt');
const db = require("./config/db.js")

const User = require("./models/User");
Expand All @@ -16,6 +17,11 @@ async function init() {
// await Goal.deleteMany({})
// await DailyEntry.deleteMany({})

// hashing "password" to be used as default password for users created here
const saltRounds = 10;
const hashedPassword = await bcrypt.hash("password", saltRounds);


let goal1 = new Goal({
goalId: 50001,
type: "sleep",
Expand All @@ -36,20 +42,46 @@ async function init() {

let user1 = new User({
userId: 10001,
email: "[email protected]",
passwordHashed: "pa55w0rd",
name: "John Smith",
email: "[email protected]",
passwordHashed: hashedPassword,
name: "Amanda Yee",
createdAt: "2024-09-01",
goals: [goal1, goal2]
goals: [goal1, goal2] // Connect default goals to user
})

let user2 = new User({
userId: 10002,
email: "[email protected]",
passwordHashed: "b0st0nuniversity",
name: "Jane Doe",
// createdAt: "2024-09-01", // testing the default param in schema works
goals: []
email: "[email protected]",
passwordHashed: hashedPassword,
name: "Abbie-Yu Luo"
})

let user3 = new User({
userId: 10003,
email: "[email protected]",
passwordHashed: hashedPassword,
name: "Chris Ceravolo"
})

let user4 = new User({
userId: 10004,
email: "[email protected]",
passwordHashed: hashedPassword,
name: "Eddie Lee"
})

let user5 = new User({
userId: 10005,
email: "[email protected]",
passwordHashed: hashedPassword,
name: "Kenny Light"
})

let user6 = new User({
userId: 10006,
email: "[email protected]",
passwordHashed: hashedPassword,
name: "Zihao Qian"
})

let dailyEntry1 = new DailyEntry({
Expand All @@ -64,10 +96,9 @@ async function init() {
})

await Promise.all([
user1.save(),
user2.save(),
goal1.save(),
goal2.save(),
user1.save(), user2.save(), user3.save(),
user4.save(), user5.save(), user6.save(),
goal1.save(), goal2.save(),
dailyEntry1.save()
])

Expand Down

0 comments on commit 480ef43

Please sign in to comment.