Error Filtering our Keys when using $addToSet


#1

I’m trying to create a list of userId’s who have voted on a particular page (id). I’m using simple schema and keep on getting the following error when using $addToSet or $push

“Exception while simulating the effect of invoking ‘thumbsUp’ Error: After filtering out keys not in the schema, your modifier is now empty(…) Error: After filtering out keys not in the schema, your modifier is now empty”

I believe it’s something to do with the way I’m creating my schema. But it looks right to me and I’ve been struggling for too long now. Not sure what else to do at this point!?!

ListSchema = new SimpleSchema({
  votingIds: {
    type: [Object],
  },
  "votingIds.$.userUnique": {
    type: String,
    optional: true,
    defaultValue: function () {
      return Meteor.userId();
    },
  },
});

Template.Seed.events({
  'click .fa-thumbs-up': function() {
    Meteor.call('thumbsUp', this._id, Meteor.userId());
  },
});

Meteor.methods({
thumbsUp: function(id, voter) {
    Seeds.update(id, {
      $inc: {
        'votes': +1
      }
    });
    Seeds.update({'_id':id}, {$addToSet: {'userUnique': voter}});
});

#2

Does anyone have any tips on this?

Or maybe even another way to go about it?

Thanks!