Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getMenteesForMentor endpoint (control, model, routes), awaiting Mongo #18

Merged
merged 7 commits into from
Dec 8, 2024

Conversation

txingxie
Copy link
Collaborator

No description provided.

@@ -19,6 +20,8 @@ app.use("/workshop", routes.workshop);

connectDB();

app.use("/api", router); // connect routes (prefix as api), what is the lin 7 logic for?: import * as routes from "./routes/index"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It imports modules user and workshop on line 18 in this file

@txingxie
Copy link
Collaborator Author

txingxie commented Dec 2, 2024

Updated mentorController with retrieval logic aligned with user object structure, abstracted user model so that scope wasn't limited to user route, resolved path import that was preventing npm run dev, included necessary nodemon dependencies?

Tested w/ Mongo Implementation & Postman:

This request: GET - http://localhost:8000/api/mentor/674d179b846a2c3069b9cfbb/mentees
Returns this:
[
{
"_id": "674d167761974e2844f17a07",
"firstName": "MenteeTestFirstName",
"lastName": "MenteeTestLastName",
"username": "MenteeTestUsername",
"email": "[email protected]",
"role": "mentee",
"workshopIDs": [],
"menteeInfo": [],
"meetingSchedule": [],
"meetings": [],
"__v": 2
},
{
"_id": "674d16a961974e2844f17a09",
"firstName": "MenteeTest2FirstName",
"lastName": "MenteeTest2LastName",
"username": "MenteeTest2Username",
"email": "[email protected]",
"role": "mentee",
"workshopIDs": [],
"menteeInfo": [],
"meetingSchedule": [],
"meetings": [],
"__v": 2
}
]

Added the following objects to Mongo:
Mentor
{"_id":{"$oid":"674d179b846a2c3069b9cfbb"},"firstName":"MentorTestFirstName","lastName":"MentorTestLastName","username":"MentorTestUsername","email":"[email protected]","role":"mentor","workshopIDs":["workshopID1"],"menteeInfo":[{"$oid":"674d167761974e2844f17a07"},{"$oid":"674d16a961974e2844f17a09"}],"meetingSchedule":[],"__v":{"$numberInt":"0"}}

Mentee 1
{"_id":{"$oid":"674d167761974e2844f17a07"},"firstName":"MenteeTestFirstName","lastName":"MenteeTestLastName","username":"MenteeTestUsername","email":"[email protected]","role":"mentee","workshopIDs":[],"menteeInfo":[],"meetingSchedule":[],"meetings":[],"__v":{"$numberInt":"2"}}

Mentee 2
{"_id":{"$oid":"674d16a961974e2844f17a09"},"firstName":"MenteeTest2FirstName","lastName":"MenteeTest2LastName","username":"MenteeTest2Username","email":"[email protected]","role":"mentee","workshopIDs":[],"menteeInfo":[],"meetingSchedule":[],"meetings":[],"__v":{"$numberInt":"2"}}

Must ensure that mentees in the 'menteeInfo' field array are represented by ObjectIDs rather than normal strings.

image

Copy link
Collaborator

@lolitaroz lolitaroz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me -- resolve merge conflicts and it can be merged!

@txingxie
Copy link
Collaborator Author

txingxie commented Dec 3, 2024

I resolved conflicts in the web editor but could someone take a second look at api/src/server.ts, specifically the app.use statements? previously there was a "app.use("/api", routes.workshop)" which might interfere with "app.use("/api", router)". Instead I added "app.use("/workshop", routes.workshop)" and kept the /user and /api statements, for which the backend worked on my local repo

Copy link
Collaborator

@lolitaroz lolitaroz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it should work! you can merge

@lolitaroz lolitaroz merged commit b2bb393 into main Dec 8, 2024
3 checks passed
@lolitaroz lolitaroz deleted the trevor/getMenteesEndpoint/39 branch December 8, 2024 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants