title: nodejs - sails.js lock query (transactions)
body: <p><strong>The case:</strong></p>
  
  <p>I'm creating an api with SAILS.js, sails.js uses <a href="https://github.com/balderdashy/waterline" rel="nofollow">waterline</a> for ORM. The api returns lets say photographs, many users are able to vote for a picture. The pictures will be ordered on number of votes.</p>
  
  <p><strong>Procedure</strong>:
  When a user votes for a song, I've to check the number of votes ("SELECT"|| picture.findById()) AND after that I have to increment that number by one ("UPDATE" picture.update). </p>
  
  <p><strong>Problem</strong>:
  <a href="http://dev.mysql.com/doc/refman/5.5/en/innodb-transactions-with-different-apis.html" rel="nofollow">transaction</a>/ locking in Sails.js, these two queries should be excecuted without having a other query modifying the picture data within the select and update query of our vote system. </p>
  
  <p>How should we perform locking/ transition in sails.js (node js framework)</p>
  
  <p>THANKS</p>