Update docs and npm version

This commit is contained in:
Timothy Warren 2014-10-30 09:48:55 -04:00
parent e9da74f819
commit 439630cdda
15 changed files with 300 additions and 50 deletions

View File

@ -110,7 +110,7 @@ module.exports = {
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -187,7 +187,48 @@ var d = {
sql += d.quoteTable(table); sql += d.quoteTable(table);
return sql; return sql;
},
/**
* SQL to insert a group of rows
*
* @param {String} table - The table to insert to
* @param {Array} [data] - The array of object containing data to insert
* @return {String}
*/
insertBatch: function(table, data) {
// Get the data values to insert, so they can
// be parameterized
var vals = [];
data.forEach(function(obj) {
Object.keys(obj).forEach(function(key) {
vals.push(obj[key]);
});
});
// Get the field names from the keys of the first
// object inserted
var fields = Object.keys(data[0]);
table = d.quoteTable(table);
var sql = "INSERT INTO " + table + " ("
+ d.quoteIdentifiers(fields).join(",")
+ ") VALUES ";
// Create placeholder groups
var params = new Array(fields.length).fill('?');
var paramString = "(" + params.join(',') + ")";
var paramList = new Array(data.length).fill(paramString);
sql += paramList.join(',');
return {
sql: sql,
values: vals
};
} }
}; };
module.exports = d;</pre> module.exports = d;</pre>
@ -211,7 +252,7 @@ module.exports = d;</pre>
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -168,7 +168,7 @@ module.exports = h;</pre>
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -141,7 +141,7 @@ query.select('foo')
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -354,7 +354,7 @@
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -170,7 +170,7 @@
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -686,7 +686,7 @@ function name, eg isNumber</p>
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -358,7 +358,7 @@
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -383,7 +383,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-800">line 800</a> <a href="query-builder.js.html#sunlight-1-line-821">line 821</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -519,7 +519,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-399">line 399</a> <a href="query-builder.js.html#sunlight-1-line-402">line 402</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -764,7 +764,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-741">line 741</a> <a href="query-builder.js.html#sunlight-1-line-744">line 744</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -955,7 +955,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-862">line 862</a> <a href="query-builder.js.html#sunlight-1-line-883">line 883</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1154,7 +1154,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-840">line 840</a> <a href="query-builder.js.html#sunlight-1-line-861">line 861</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1355,7 +1355,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-823">line 823</a> <a href="query-builder.js.html#sunlight-1-line-844">line 844</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1546,7 +1546,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-851">line 851</a> <a href="query-builder.js.html#sunlight-1-line-872">line 872</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1641,7 +1641,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-346">line 346</a> <a href="query-builder.js.html#sunlight-1-line-349">line 349</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1788,7 +1788,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-623">line 623</a> <a href="query-builder.js.html#sunlight-1-line-626">line 626</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1875,7 +1875,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-722">line 722</a> <a href="query-builder.js.html#sunlight-1-line-725">line 725</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1962,7 +1962,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-686">line 686</a> <a href="query-builder.js.html#sunlight-1-line-689">line 689</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2147,7 +2147,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-472">line 472</a> <a href="query-builder.js.html#sunlight-1-line-475">line 475</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2357,7 +2357,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-764">line 764</a> <a href="query-builder.js.html#sunlight-1-line-767">line 767</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2393,6 +2393,194 @@
</dd>
<dt>
<h4 class="name" id="insertBatch"><span class="type-signature"></span>insertBatch<span class="signature">(table, data, callback)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>Insert multiple sets of rows at a time</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>table</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last"><p>The table to insert into</p></td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last"><p>The array of objects containing data rows to insert</p></td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last"><p>Callback for handling database response</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-787">line 787</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>void</p>
</div>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">query.insertBatch(&#x27;foo&#x27;,[{id:1,val:&#x27;bar&#x27;},{id:2,val:&#x27;baz&#x27;}], callbackFunction);S</pre>
</dd> </dd>
@ -2583,7 +2771,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-598">line 598</a> <a href="query-builder.js.html#sunlight-1-line-601">line 601</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2809,7 +2997,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-421">line 421</a> <a href="query-builder.js.html#sunlight-1-line-424">line 424</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2988,7 +3176,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-674">line 674</a> <a href="query-builder.js.html#sunlight-1-line-677">line 677</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3214,7 +3402,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-434">line 434</a> <a href="query-builder.js.html#sunlight-1-line-437">line 437</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3405,7 +3593,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-646">line 646</a> <a href="query-builder.js.html#sunlight-1-line-649">line 649</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3493,7 +3681,7 @@ prefixed with 'OR'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-699">line 699</a> <a href="query-builder.js.html#sunlight-1-line-702">line 702</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3678,7 +3866,7 @@ prefixed with 'OR'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-486">line 486</a> <a href="query-builder.js.html#sunlight-1-line-489">line 489</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3904,7 +4092,7 @@ prefixed with 'OR'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-447">line 447</a> <a href="query-builder.js.html#sunlight-1-line-450">line 450</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3992,7 +4180,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-711">line 711</a> <a href="query-builder.js.html#sunlight-1-line-714">line 714</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4218,7 +4406,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-460">line 460</a> <a href="query-builder.js.html#sunlight-1-line-463">line 463</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4403,7 +4591,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-512">line 512</a> <a href="query-builder.js.html#sunlight-1-line-515">line 515</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4562,7 +4750,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-536">line 536</a> <a href="query-builder.js.html#sunlight-1-line-539">line 539</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4721,7 +4909,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-560">line 560</a> <a href="query-builder.js.html#sunlight-1-line-563">line 563</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4860,7 +5048,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-365">line 365</a> <a href="query-builder.js.html#sunlight-1-line-368">line 368</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -5042,7 +5230,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-572">line 572</a> <a href="query-builder.js.html#sunlight-1-line-575">line 575</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -5252,7 +5440,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-782">line 782</a> <a href="query-builder.js.html#sunlight-1-line-803">line 803</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -5437,7 +5625,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-500">line 500</a> <a href="query-builder.js.html#sunlight-1-line-503">line 503</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -5596,7 +5784,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-524">line 524</a> <a href="query-builder.js.html#sunlight-1-line-527">line 527</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -5755,7 +5943,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="query-builder.js.html">query-builder.js</a>, <a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-548">line 548</a> <a href="query-builder.js.html#sunlight-1-line-551">line 551</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -5819,7 +6007,7 @@ prefixed with 'OR NOT'</p>
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -466,7 +466,7 @@
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -158,7 +158,7 @@
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -129,7 +129,7 @@ module.exports = nodeQuery.init;</pre>
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -344,18 +344,21 @@ var QueryBuilder = function(driver, adapter) {
_p.appendMap(args.conj, str, 'whereIn'); _p.appendMap(args.conj, str, 'whereIn');
}, },
run: function(type, table, callback, sql, vals) { run: function(type, table, callback, sql, vals) {
if ( ! sql) if ( ! sql)
{ {
sql = _p.compile(type, table); sql = _p.compile(type, table);
} }
//console.log(sql);
//console.log('------------------------');
if ( ! vals) if ( ! vals)
{ {
vals = state.values.concat(state.whereValues); vals = state.values.concat(state.whereValues);
} }
//console.log(sql);
//console.log(vals);
//console.log('------------------------');
// Reset the state so another query can be built // Reset the state so another query can be built
_p.resetState(); _p.resetState();
@ -838,6 +841,7 @@ var QueryBuilder = function(driver, adapter) {
*/ */
this.insert = function(/* table, data, callback */) { this.insert = function(/* table, data, callback */) {
var args = getArgs('table:string, [data]:object, callback:function', arguments); var args = getArgs('table:string, [data]:object, callback:function', arguments);
args.table = driver.quoteTable(args.table);
if (args.data) { if (args.data) {
this.set(args.data); this.set(args.data);
} }
@ -846,6 +850,23 @@ var QueryBuilder = function(driver, adapter) {
_p.run('insert', args.table, args.callback); _p.run('insert', args.table, args.callback);
}; };
/**
* Insert multiple sets of rows at a time
*
* @param {String} table - The table to insert into
* @param {Array} data - The array of objects containing data rows to insert
* @param {Function} callback - Callback for handling database response
* @example query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}], callbackFunction);S
* @return void
*/
this.insertBatch = function(/* table, data, callback */) {
var args = getArgs('table:string, data:array, callback:function', arguments);
var batch = driver.insertBatch(args.table, args.data);
// Run the query
_p.run('', '', args.callback, batch.sql, batch.values);
};
/** /**
* Run the generated update query * Run the generated update query
* *
@ -873,7 +894,7 @@ var QueryBuilder = function(driver, adapter) {
* @return void * @return void
*/ */
this.delete = function (/*table, [where], callback*/) { this.delete = function (/*table, [where], callback*/) {
var args = getArgs('table:string, [where], callback:function', arguments); var args = getArgs('table:string, [where]:object, callback:function', arguments);
if (args.where) if (args.where)
{ {
@ -962,7 +983,7 @@ module.exports = QueryBuilder;</pre>
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -187,7 +187,7 @@ module.exports = QueryParser;
<span class="jsdoc-message"> <span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Oct 28th 2014 using the <a on Thu Oct 30th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>. href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span> </span>
</footer> </footer>

View File

@ -1,6 +1,6 @@
{ {
"name": "ci-node-query", "name": "ci-node-query",
"version": "0.0.4", "version": "0.1.0",
"description": "A query builder for node based on the one in CodeIgniter", "description": "A query builder for node based on the one in CodeIgniter",
"author": "Timothy J Warren <tim@timshomepage.net>", "author": "Timothy J Warren <tim@timshomepage.net>",
"engines": { "engines": {