-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
32 additions
and
5 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
9 changes: 9 additions & 0 deletions
9
server/src/domain/interface/repositories/INotificationRepository.ts
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import INotification from "../../entities/INotification"; | ||
|
||
export default interface INotificationRepository { | ||
create(notification: INotification): Promise<void>; | ||
findByPatientId(patientId: string): Promise<INotification[] | null>; | ||
findByDoctorId(doctorId: string): Promise<INotification[] | null>; | ||
clear(id: string): Promise<void>; | ||
clearAll(notificationIds: string[]): Promise<void>; | ||
} |
23 changes: 23 additions & 0 deletions
23
server/src/infrastructure/repositories/NotificationRepository.ts
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import INotification from "../../domain/entities/INotification"; | ||
import INotificationRepository from "../../domain/interface/repositories/INotificationRepository"; | ||
import NotificationModel from "../database/NotificationMode"; | ||
|
||
export default class NotificationRepository implements INotificationRepository { | ||
model = NotificationModel | ||
|
||
async create(notification: INotification): Promise<void> { | ||
await this.model.create(notification) | ||
} | ||
async findByPatientId(patientId: string): Promise<INotification[] | null> { | ||
return this.model.find({ patientId }) | ||
} | ||
async findByDoctorId(doctorId: string): Promise<INotification[] | null> { | ||
return this.model.find({ doctorId }) | ||
} | ||
async clear(id: string): Promise<void> { | ||
await this.model.findByIdAndDelete(id); | ||
} | ||
async clearAll(notificationIds: string[]): Promise<void> { | ||
await this.model.deleteMany({ _id: { $in: notificationIds } }) | ||
} | ||
} |