-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from advanced-computer-lab-2023/VCP-10
fixing the problem with user id
- Loading branch information
Showing
2 changed files
with
11 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import AppointmentModel from '../models/Appointment.js'; | ||
import mongoose from 'mongoose'; | ||
|
||
class AppointmentRepository { | ||
async findAppointmentsByUserId(id) { | ||
// const objectId = mongoose.Types.ObjectId(id) | ||
// console.log(objectId); | ||
const appointments = await AppointmentModel.find({}); | ||
return appointments.filter((appointment) => appointment.patientId.toString() === id.toString() | ||
); | ||
} | ||
async findAppointmentsByUserId(id) { | ||
const userID = new mongoose.Types.ObjectId(id); | ||
const appointments = await AppointmentModel.find({ | ||
$or: [{ patientId: userID }, { doctorId: userID }], | ||
}); | ||
return appointments; | ||
} | ||
} | ||
|
||
export default AppointmentRepository; |