Skip to content

Commit afe154e

Browse files
committed
add lean() with populate() in appointment queries
1 parent 2940aed commit afe154e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/controllers/aptcontrol.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const getAppointments = async (req, res) => {
3737
const appointments = await Appointment.find(query)
3838
.populate('patient', 'name email')
3939
.populate('doctor', 'name spec')
40-
.populate('dept', 'dept');
40+
.populate('dept', 'dept')
41+
.lean();
4142

4243
res.json(appointments);
4344
} catch (err) {
@@ -51,7 +52,8 @@ const getAppointmentById = async (req, res) => {
5152
const appointment = await Appointment.findById(req.params.id)
5253
.populate('patient', 'name email')
5354
.populate('doctor', 'name spec')
54-
.populate('dept', 'dept');
55+
.populate('dept', 'dept')
56+
.lean();
5557

5658
if (!appointment) return res.status(404).json({ message: 'Appointment not found' });
5759

0 commit comments

Comments
 (0)