From 37a2226aec786a624acd8ed3f8b450ad033d8dc6 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 13 Mar 2017 02:30:28 +0100 Subject: token count --- lib/okpush/db.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/okpush/db.js b/lib/okpush/db.js index 001c06b5..1a2099d0 100644 --- a/lib/okpush/db.js +++ b/lib/okpush/db.js @@ -68,7 +68,7 @@ function addToken (data) { } function getAllIOSTokens (channel, cb) { PushToken.distinct("token", { channel: channel, platform: 'ios' }, function (err, items) { - if (err) return cb(err, null) + if (err) return cb(err, []) var items = _.map(items, function (item) { return item.token }) @@ -77,7 +77,7 @@ function getAllIOSTokens (channel, cb) { } function getAllAndroidTokens (channel, cb) { PushToken.distinct("token", { channel: channel, platform: 'android' }, function (err, items) { - if (err) return cb(err, null) + if (err) return cb(err, []) var items = _.map(items, function (item) { return item.token }) @@ -86,7 +86,7 @@ function getAllAndroidTokens (channel, cb) { } function getAllTokens (channel, cb) { PushToken.distinct("token", { channel: channel }, function (err, items) { - if (err) return cb(err, null) + if (err) return cb(err, []) var items = _.map(items, function (item) { return _.pick(item, ['platform', 'token']) }) @@ -101,8 +101,8 @@ function getDeviceCount (channels, cb) { get_next() function get_next() { var channel = channels.pop() - PushToken.count({ channel: channel }, function(err, count){ - countz[channel] = count + PushToken.distinct("token", { channel: channel }, function(err, tokens){ + countz[channel] = tokens.length if (channels.length) { return get_next() } -- cgit v1.2.3-70-g09d2