summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/okpush/db.js20
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/okpush/db.js b/lib/okpush/db.js
index 1a2099d0..09afdf34 100644
--- a/lib/okpush/db.js
+++ b/lib/okpush/db.js
@@ -67,28 +67,22 @@ function addToken (data) {
return new PushToken(data).save()
}
function getAllIOSTokens (channel, cb) {
- PushToken.distinct("token", { channel: channel, platform: 'ios' }, function (err, items) {
+ PushToken.distinct("token", { channel: channel, platform: 'ios' }, function (err, tokens) {
if (err) return cb(err, [])
- var items = _.map(items, function (item) {
- return item.token
- })
- return cb(null, items)
+ return cb(null, tokens)
})
}
function getAllAndroidTokens (channel, cb) {
- PushToken.distinct("token", { channel: channel, platform: 'android' }, function (err, items) {
+ PushToken.distinct("token", { channel: channel, platform: 'android' }, function (err, tokens) {
if (err) return cb(err, [])
- var items = _.map(items, function (item) {
- return item.token
- })
- return cb(null, items)
+ return cb(null, tokens)
})
}
function getAllTokens (channel, cb) {
- PushToken.distinct("token", { channel: channel }, function (err, items) {
+ PushToken.find({ channel: channel }, function (err, items) {
if (err) return cb(err, [])
- var items = _.map(items, function (item) {
- return _.pick(item, ['platform', 'token'])
+ var items = items.map(function (item) {
+ return { platform: item.get('platform'), token: item.get('token') }
})
return cb(null, items)
})