diff --git a/src/services/attendee/attendee-router.ts b/src/services/attendee/attendee-router.ts index 41d827e..4401cbb 100644 --- a/src/services/attendee/attendee-router.ts +++ b/src/services/attendee/attendee-router.ts @@ -185,11 +185,11 @@ attendeeRouter.get( async (req, res, next) => { try { const attendeeData = AttendeeFilterValidator.parse(req.body); + const projection = Object.assign({}, ...attendeeData.projection); const attendees = await Database.ATTENDEE.find( - attendeeData.in, - attendeeData.out + attendeeData.filter, + projection ); - return res.status(StatusCodes.OK).json(attendees); } catch (error) { next(error); diff --git a/src/services/attendee/attendee-schema.ts b/src/services/attendee/attendee-schema.ts index e0069dd..9e3088b 100644 --- a/src/services/attendee/attendee-schema.ts +++ b/src/services/attendee/attendee-schema.ts @@ -94,6 +94,8 @@ export const EventIdValidator = z.object({ export const PartialAttendeeValidator = AttendeeValidator.partial(); export const AttendeeFilterValidator = z.object({ - in: PartialAttendeeValidator, - out: z.map(PartialAttendeeValidator.keyof(), z.number().min(0).max(1)), + filter: PartialAttendeeValidator, + projection: z.array( + z.record(PartialAttendeeValidator.keyof(), z.number().min(1).max(1)) + ), });