mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-26 15:29:22 +00:00
28 lines
512 B
TypeScript
28 lines
512 B
TypeScript
|
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
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
}
|