title: implement voting system using node.js, mongodb and ejs
body: <p>I'm pretty new to node.JS and ejs. I have searched <code>how to implement real-time voting system like Stackoverflow voting</code> using the mentioned technology. But I don't have any Idea how to do it. </p>
  
  <p>here is my front-end code:</p>
  
  <pre><code>&lt;% for (var i = 0; i &lt; gamePasses.length; i++) {%&gt;
      &lt;form dir="ltr"&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;%= i + 1 %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%= gamePasses[i].teamName %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%= gamePasses[i].password %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%= gamePasses[i].votes %&gt;
              &lt;/td&gt;
              &lt;td onclick="vote('&lt;%= gamePasses[i].password %&gt;')"&gt;
                  &lt;i class="material-icons"&gt;
                      thumb_up
                  &lt;/i&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;/form&gt;
  &lt;% } %&gt;
  
  &lt;script&gt;
      function vote(pass) {
          $.post('/user/vote/' + pass)
      }
      function passSubmit() {
          $.post('/user/gamePassword', {
              gamePassword: $('#password').val()
          }).done(() =&gt; {
              window.location.assign('/user/scoreboard')
          })
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>back-end code: </p>
  
  <pre><code>uter.post('/vote/:gamePassword', (req, res) =&gt; {
      gamePassword = req.params.gamePassword;
      gamePassModel.find({password: gamePassword}, (err, result) =&gt; {
          if (err) console.log(err)
          else {
              result.votes += 1
              result.save((err) =&gt; {
                  if (err) console.log(err)
              })
          }
      })
  })
  </code></pre>
  
  <p>This code problems are:</p>
  
  <ol>
  <li><p>Doesn't support real-time voting</p></li>
  <li><p>each user can votes many times</p></li>
  </ol>
  
  <p>I will be thankful if anyone could help me</p>