-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from BUMETCS673/add_team_members_to_initdb
add all team members into initdb file
- Loading branch information
Showing
1 changed file
with
44 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
|
@@ -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", | ||
|
@@ -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({ | ||
|
@@ -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() | ||
]) | ||
|
||
|