summaryrefslogtreecommitdiff
path: root/src/api/endpoints/notifications/get_unread_count.ts
blob: 9514e78713a201d6431c42534a54568c144fb0ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
 * Module dependencies
 */
import Notification from '../../models/notification';

/**
 * Get count of unread notifications
 *
 * @param {any} params
 * @param {any} user
 * @return {Promise<any>}
 */
module.exports = (params, user) => new Promise(async (res, rej) => {
	const count = await Notification
		.count({
			notifiee_id: user._id,
			is_read: false
		});

	res({
		count: count
	});
});