Skip to content

Commit

Permalink
Vote method.
Browse files Browse the repository at this point in the history
  • Loading branch information
wangbus committed Dec 24, 2015
1 parent cb73ee4 commit 49a39ca
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions polls/index.js
Expand Up @@ -73,13 +73,12 @@ polls.exists = function(threadId) {
};

polls.vote = function(pollId, answerIds, userId) {
pollId = helper.deslugify(pollId);
userId = helper.deslugify(userId);
answerIds = answerIds.map(function(answerId) { return helper.deslugify(answerId); });

return Promise.each(answerIds, function(answerId) {
q = 'INSERT INTO poll_responses (poll_id, answer_id, user_id) VALUES ($1, $2, $3)';
return db.sqlQuery(q, [pollId, answerId, userId]);
q = 'INSERT INTO poll_responses (answer_id, user_id) VALUES ($1, $2)';
return db.sqlQuery(q, [answerId, userId]);
});
};

Expand Down

0 comments on commit 49a39ca

Please sign in to comment.