diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-02-16 18:32:08 +0100 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-02-16 18:32:08 +0100 |
| commit | d3d195470caef02891de58ed25b92a02c088c37d (patch) | |
| tree | af3531e9efe2fe32407b7bde4fc1828e60564b98 /lib/okpush/db.js | |
| parent | f40e2286faef696c25a81c04635aaf737606a39a (diff) | |
routes
Diffstat (limited to 'lib/okpush/db.js')
| -rw-r--r-- | lib/okpush/db.js | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/okpush/db.js b/lib/okpush/db.js index 844bccae..ad18b7b3 100644 --- a/lib/okpush/db.js +++ b/lib/okpush/db.js @@ -10,7 +10,7 @@ function init (config) { mongoose.connection.on('error', errorHandler) var pushTokenSchema = new db.Schema({ - type: { + platform: { type: 'String', required: true, lowercase: true, @@ -62,13 +62,8 @@ function errorHandler (error) { /* devices / tokens */ -function addToken (deviceType, token, channel) { - var pushItem = new PushToken({ - type: deviceType, - token: token, - channel: channel - }) - pushItem.save() +function addToken (data) { + return new PushToken(data).save() } function getAllTokens (channel, cb) { PushToken.find({ channel: channel }, function (err, items) { @@ -79,8 +74,8 @@ function getAllTokens (channel, cb) { return cb(null, items) }) } -function removeToken (token, channel) { - PushToken.find({ token: token, channel: channel }).remove().exec() +function removeToken (data) { + PushToken.find(data).remove().exec() } function getDeviceCount (channel, cb) { PushToken.count({ channel: channel }, cb) |
