diff --git a/lib/server/server.js b/lib/server/server.js index 31524d3..5034fdf 100644 --- a/lib/server/server.js +++ b/lib/server/server.js @@ -1,4 +1,5 @@ Push.appCollection = new Mongo.Collection('_raix_push_app_tokens'); +Push.appCollection._ensureIndex({ userId: 1 }); Push.addListener('token', function(currentToken, value) { if (value) { @@ -33,7 +34,9 @@ Meteor.methods({ // lookup app by id if one was included if (options.id) { - doc = Push.appCollection.findOne({ _id: options.id }); + doc = Push.appCollection.findOne({_id: options.id}); + } else if (options.userId) { + doc = Push.appCollection.findOne({userId: options.userId}); } // No doc was found - we check the database to see if