Skip to content

Commit

Permalink
descending appointment history of doctor
Browse files Browse the repository at this point in the history
  • Loading branch information
sidhant-khamankar committed Apr 12, 2021
1 parent 0544913 commit 3de5879
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion backend/routes/doctors.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,15 @@ router.route("/appointments").post(async (req, res) => {
const appointments = await Appointment.find({
doctorId: doctorId,
});
res.status(200).json(appointments);
// res.status(200).json(appointments);
const sortedAppointments = appointments.sort((a, b) => {
return (
Date.parse(b.date + "T" + b.slotTime) -
Date.parse(a.date + "T" + a.slotTime)
);
});

res.status(200).json(sortedAppointments);
} catch (err) {
console.log(err);
res.status(400).json(err);
Expand Down

0 comments on commit 3de5879

Please sign in to comment.