title: Update records in a loop in postgresql efficiently
body: <p>I have a bunch of records that looks like this:</p>
  <pre><code>[
    CategoryEntity { id: 11, position: 2 },
    CategoryEntity { id: 12, position: 1 },
    CategoryEntity { id: 13, position: 3 },
    CategoryEntity { id: 14, position: 4 },
    CategoryEntity { id: 15, position: 5 },
    CategoryEntity { id: 17, position: 6 },
    CategoryEntity { id: 16, position: 7 },
    CategoryEntity { id: 19, position: 8 },
    CategoryEntity { id: 18, position: 9 },
    CategoryEntity { id: 20, position: 10 }
  ]
  </code></pre>
  <p>These are the values I need to update in the category table. I understand they all need to be done withing a transaction, but I'm not sure that executing multiple <code>await update</code>s would be the right way to approach this issue.</p>
  <p>What is the right practice here?</p>
  <p>P.S.</p>
  <p>I'm using typeorm but it allows to throw raw queries so a raw query would be welcome as well.</p>
  <p>Thank you.</p>