1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 08:35:17 +00:00

Can get the number of unread notifications

This commit is contained in:
2019-12-27 18:56:22 +01:00
parent 820b861ef8
commit 704e05bafe
3 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,28 @@
import { DatabaseHelper } from "./DatabaseHelper";
/**
* Notifications helper
*
* @author Pierre HUBERT
*/
const NOTIFICATIONS_TABLE = "comunic_notifications";
export class NotificationsHelper {
/**
* Count the number of unread notifications of a user
*
* @param userID Target user ID
*/
public static async CountUnread(userID: number) : Promise<number> {
return await DatabaseHelper.Count({
table: NOTIFICATIONS_TABLE,
where: {
dest_user_id: userID,
seen: 0
}
});
}
}