tududi/backend/modules/notifications/repository.js
Chris 542be2c1e9
Fix bug 366 (#764)
* Optimize DB

* Clean up names

* fixup! Clean up names

* fixup! fixup! Clean up names
2026-01-07 18:18:07 +02:00

30 lines
774 B
JavaScript

'use strict';
const BaseRepository = require('../../shared/database/BaseRepository');
const { Notification } = require('../../models');
class NotificationsRepository extends BaseRepository {
constructor() {
super(Notification);
}
async getUserNotifications(userId, options) {
return Notification.getUserNotifications(userId, options);
}
async getUnreadCount(userId) {
return Notification.getUnreadCount(userId);
}
async markAllAsRead(userId) {
return Notification.markAllAsRead(userId);
}
async findByIdAndUser(id, userId, options = {}) {
return this.model.findOne({
where: { id, user_id: userId, ...options },
});
}
}
module.exports = new NotificationsRepository();