Skip to content

Commit

Permalink
Merge pull request #314 from sirpy/patch-1
Browse files Browse the repository at this point in the history
feat: support lookup by userid to prevent duplicate records for same user
  • Loading branch information
Morten N.O. Nørgaard Henriksen authored Nov 28, 2017
2 parents f4957ad + 8f8fce3 commit 480efdb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/server/server.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 480efdb

Please sign in to comment.