diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-03-29 04:55:42 +0200 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-03-29 04:56:03 +0200 |
| commit | ee9cea7b654dc2393cb3c37d951780012adb4d61 (patch) | |
| tree | 5935e2a5c99dbdddc8dbc4af3124ba92810e4705 /lib/okpush | |
| parent | 37a2226aec786a624acd8ed3f8b450ad033d8dc6 (diff) | |
fix db calls
Diffstat (limited to 'lib/okpush')
| -rw-r--r-- | lib/okpush/db.js | 20 |
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) }) |
