From cf85cc2b75b9c3ead3a693b6fa0feeca5b9e70ba Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 19 Feb 2017 01:23:53 +0100 Subject: counts --- lib/okpush/db.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lib/okpush/db.js') diff --git a/lib/okpush/db.js b/lib/okpush/db.js index ad18b7b3..f64acf69 100644 --- a/lib/okpush/db.js +++ b/lib/okpush/db.js @@ -77,8 +77,21 @@ function getAllTokens (channel, cb) { function removeToken (data) { PushToken.find(data).remove().exec() } -function getDeviceCount (channel, cb) { - PushToken.count({ channel: channel }, cb) +function getDeviceCount (channels, cb) { + var countz = {} + get_next() + function get_next() { + var channel = channels.pop() + PushToken.count({ channel: channel }, function(err, count){ + countz[channel] = count + if (channels.length) { + return get_next() + } + else { + cb(countz) + } + }) + } } /* notifications */ -- cgit v1.2.3-70-g09d2