NotificationRepository.ts 855 B

12345678910111213141516171819202122232425262728
  1. import type {Collection} from "pinia-orm";
  2. import Notification from "~/models/Core/Notification";
  3. import BaseRepository from "~/stores/repositories/BaseRepository";
  4. class NotificationRepository extends BaseRepository {
  5. use = Notification
  6. /**
  7. * On récupère les Notifications via le store
  8. */
  9. public getNotifications(): Collection<Notification> {
  10. return this.getQuery()
  11. .orderBy('createDate', 'desc')
  12. .get() as Collection<Notification>
  13. }
  14. /**
  15. * Retourne les notifications non lues
  16. */
  17. public getUnreadNotifications(): Collection<Notification> {
  18. return this.getQuery()
  19. .where((val) => val.notificationUsers?.length === 0 )
  20. .orderBy('createDate', 'desc')
  21. .get() as Collection<Notification>
  22. }
  23. }
  24. export default NotificationRepository