Fetch User's Upcoming Interested/Attending Events#60
Open
jimmywin656 wants to merge 4 commits intomainfrom
Open
Fetch User's Upcoming Interested/Attending Events#60jimmywin656 wants to merge 4 commits intomainfrom
jimmywin656 wants to merge 4 commits intomainfrom
Conversation
lxkedinh
requested changes
Apr 25, 2024
Comment on lines
+210
to
+228
| const userEvents = await prisma.events.findMany({ | ||
| where: { | ||
| eventAttendees: { | ||
| some: { | ||
| userId: userId, | ||
| status: { in: ["Interested", "Attending"] }, | ||
| }, | ||
| }, | ||
| startDate: { gte: currentDate }, | ||
| }, | ||
| select: { | ||
| eventId: true, | ||
| startDate: true, | ||
| eventAttendees: { | ||
| select: { status: true }, | ||
| where: { userId: userId }, | ||
| }, | ||
| }, | ||
| }); |
Collaborator
There was a problem hiding this comment.
These will be displayed as a list of event info cards for the user, let's sort them by ascending start date for convenience.
Comment on lines
+411
to
+412
| router.get( | ||
| "/:userId/events", |
Collaborator
There was a problem hiding this comment.
After looking into it a bit more, I think it makes more sense to move this to the user router instead so it becomes GET /users/:userId/events. This follows REST API convention more since we're interested in the events (a subcollection) of a particular user with userId in the users collection.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implemented a GET route that returns all of a user's upcoming events only if they marked them as "Interested" or "Attending". To implement the route, I created a new controller function called getUserEvents and brought in the userIdValidator to validate the userId.