Batch update in knex
<p>I'd like to perform a batch update using <a href="http://knexjs.org/" rel="noreferrer">Knex.js</a></p>

<p>For example: </p>

<pre><code>'UPDATE foo SET [theValues] WHERE idFoo = 1'
'UPDATE foo SET [theValues] WHERE idFoo = 2'
</code></pre>

<p>with values:</p>

<pre><code>{ name: "FooName1", checked: true } // to `idFoo = 1`
{ name: "FooName2", checked: false } // to `idFoo = 2`
</code></pre>

<p>I was using <a href="https://github.com/mysqljs/mysql#multiple-statement-queries" rel="noreferrer">node-mysql</a> previously, which allowed multiple-statements. While using that I simply built a mulitple-statement query string and just send that through the wire in a single run.</p>

<p>I'm not sure how to achieve the same with Knex. I can see <code>batchInsert</code> as an API method I can use, but nothing as far as <code>batchUpdate</code> is concerned.</p>

<h3>Note:</h3>

<ul>
<li><p>I can do an async iteration and update each row separately. That's bad cause it means there's gonna be lots of roundtrips from the server to the DB</p></li>
<li><p>I can use the <code>raw()</code> thing of Knex and probably do something similar to what I do with node-mysql. However that defeats the whole knex purpose of being a DB abstraction layer (It introduces strong DB coupling)</p></li>
</ul>

<p>So I'd like to do this using something "knex-y".</p>

<p>Any ideas welcome.</p>