NotificationRepository.ts 905 B

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