$addToSet and $in inside a AutoForm.addHooks


#1

I am making a creating a upvote/downvote system and I am trying to figure out a way to add the user who submitted the post to an array on submit.

The idea is the user fills out the form and submits it then the AutoForm.addHooks automatically increase the upvotes 1 and adds the user to upVoters.

I know this wrong but I assume it might look something like this:

AutoForm.addHooks('insertArticles', {
  onSuccess: function(doc) {
    Articles.update({
         _id: this._id
      },
      {
        $addToSet: {
          upVoters: Meteor.userId()
        },
        $inc: {
          upvote: 1
        }
      }
    );
    Router.go('formDisplay',{_id: this.docId});
  }
})