From d3d195470caef02891de58ed25b92a02c088c37d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 16 Feb 2017 18:32:08 +0100 Subject: routes --- lib/okpush/db.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'lib/okpush/db.js') 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) -- cgit v1.2.3-70-g09d2