-
Notifications
You must be signed in to change notification settings - Fork 0
Fetch User's Upcoming Interested/Attending Events #60
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
base: main
Are you sure you want to change the base?
Conversation
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 }, | ||
}, | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will be displayed as a list of event info cards for the user, let's sort them by ascending start date for convenience.
router.get( | ||
"/:userId/events", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.