Update docs

This commit is contained in:
Timothy Warren 2014-11-05 17:08:17 -05:00
parent 456d68c016
commit 139fdcbac8
14 changed files with 582 additions and 86 deletions

View File

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

View File

@ -252,7 +252,7 @@ module.exports = d;</pre>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Nov 4th 2014 using the <a
on Wed Nov 5th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>

View File

@ -121,6 +121,57 @@ var h = {
isScalar: function(obj) {
var scalar = ['string', 'number', 'boolean'];
return scalar.indexOf(h.type(obj)) !== -1;
},
/**
* Get a list of values with a common key from an array of objects
*
* @param {Array} arr - The array of objects to search
* @param {String} key - The key of the object to get
* @return {Array}
*/
arrayPluck: function(arr, key) {
var output = [];
// Empty case
if (arr.length === 0) return output;
arr.forEach(function(obj) {
if ( ! h.isUndefined(obj[key]))
{
output.push(obj[key]);
}
});
return output;
},
/**
* Determine if a value matching the passed regular expression is
* in the passed array
*
* @param {Array} arr - The array to search
* @param {RegExp} pattern - The pattern to match
* @return {Boolean} - If an array item matches the pattern
*/
regexInArray: function(arr, pattern) {
// Empty case(s)
if ( ! h.isArray(arr)) return false;
if (arr.length === 0) return false;
var i, l = arr.length;
for(i=0; i&lt; l; i++)
{
// Recurse for nested arrays
if (Array.isArray(arr[i]))
{
return h.regexInArray(arr[i], pattern);
}
// Short circuit if any items match
if (pattern.test(arr[i])) return true;
}
return false;
}
};
@ -168,7 +219,7 @@ module.exports = h;</pre>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Nov 4th 2014 using the <a
on Wed Nov 5th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>

View File

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

View File

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

View File

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

View File

@ -190,7 +190,7 @@ function name, eg isNumber</p>
<ul class="dummy">
<li>
<a href="helpers.js.html">helpers.js</a>,
<a href="helpers.js.html#sunlight-1-line-55">line 55</a>
<a href="helpers.js.html#sunlight-1-line-106">line 106</a>
</li>
</ul>
</dd>
@ -215,6 +215,173 @@ function name, eg isNumber</p>
<dl>
<dt>
<h4 class="name" id="arrayPluck"><span class="type-signature">&lt;static> </span>arrayPluck<span class="signature">(arr, key)</span><span class="type-signature"> &rarr; {Array}</span></h4>
</dt>
<dd>
<div class="description">
<p>Get a list of values with a common key from an array of objects</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>arr</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last"><p>The array of objects to search</p></td>
</tr>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last"><p>The key of the object to get</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="helpers.js.html">helpers.js</a>,
<a href="helpers.js.html#sunlight-1-line-57">line 57</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="isScalar"><span class="type-signature">&lt;static> </span>isScalar<span class="signature">(obj)</span><span class="type-signature"> &rarr; {bool}</span></h4>
@ -355,6 +522,180 @@ function name, eg isNumber</p>
</dd>
<dt>
<h4 class="name" id="regexInArray"><span class="type-signature">&lt;static> </span>regexInArray<span class="signature">(arr, pattern)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
</dt>
<dd>
<div class="description">
<p>Determine if a value matching the passed regular expression is
in the passed array</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>arr</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last"><p>The array to search</p></td>
</tr>
<tr>
<td class="name"><code>pattern</code></td>
<td class="type">
<span class="param-type">RegExp</span>
</td>
<td class="description last"><p>The pattern to match</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="helpers.js.html">helpers.js</a>,
<a href="helpers.js.html#sunlight-1-line-80">line 80</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<ul>
<li>If an array item matches the pattern</li>
</ul>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
</dd>
@ -686,7 +1027,7 @@ function name, eg isNumber</p>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Nov 4th 2014 using the <a
on Wed Nov 5th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>

View File

@ -334,6 +334,105 @@
<h3 class="subsection-title">Methods</h3>
<dl>
<dt>
<h4 class="name" id="getQuery"><span class="type-signature"></span>getQuery<span class="signature">()</span><span class="type-signature"> &rarr; {queryBuilder}</span></h4>
</dt>
<dd>
<div class="description">
<p>Return an existing query builder instance</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="node-query.js.html">node-query.js</a>,
<a href="node-query.js.html#sunlight-1-line-44">line 44</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">queryBuilder</span>
</dd>
</dl>
</dd>
</dl>
@ -358,7 +457,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Nov 4th 2014 using the <a
on Wed Nov 5th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>

View File

@ -383,7 +383,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-825">line 825</a>
<a href="query-builder.js.html#sunlight-1-line-826">line 826</a>
</li>
</ul>
</dd>
@ -519,7 +519,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-405">line 405</a>
<a href="query-builder.js.html#sunlight-1-line-406">line 406</a>
</li>
</ul>
</dd>
@ -764,7 +764,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-747">line 747</a>
<a href="query-builder.js.html#sunlight-1-line-748">line 748</a>
</li>
</ul>
</dd>
@ -955,7 +955,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-887">line 887</a>
<a href="query-builder.js.html#sunlight-1-line-888">line 888</a>
</li>
</ul>
</dd>
@ -1154,7 +1154,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-865">line 865</a>
<a href="query-builder.js.html#sunlight-1-line-866">line 866</a>
</li>
</ul>
</dd>
@ -1355,7 +1355,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-848">line 848</a>
<a href="query-builder.js.html#sunlight-1-line-849">line 849</a>
</li>
</ul>
</dd>
@ -1546,7 +1546,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-876">line 876</a>
<a href="query-builder.js.html#sunlight-1-line-877">line 877</a>
</li>
</ul>
</dd>
@ -1641,7 +1641,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-352">line 352</a>
<a href="query-builder.js.html#sunlight-1-line-353">line 353</a>
</li>
</ul>
</dd>
@ -1788,7 +1788,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-629">line 629</a>
<a href="query-builder.js.html#sunlight-1-line-630">line 630</a>
</li>
</ul>
</dd>
@ -1875,7 +1875,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-728">line 728</a>
<a href="query-builder.js.html#sunlight-1-line-729">line 729</a>
</li>
</ul>
</dd>
@ -1962,7 +1962,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-692">line 692</a>
<a href="query-builder.js.html#sunlight-1-line-693">line 693</a>
</li>
</ul>
</dd>
@ -2147,7 +2147,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-478">line 478</a>
<a href="query-builder.js.html#sunlight-1-line-479">line 479</a>
</li>
</ul>
</dd>
@ -2357,7 +2357,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-770">line 770</a>
<a href="query-builder.js.html#sunlight-1-line-771">line 771</a>
</li>
</ul>
</dd>
@ -2539,7 +2539,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-790">line 790</a>
<a href="query-builder.js.html#sunlight-1-line-791">line 791</a>
</li>
</ul>
</dd>
@ -2771,7 +2771,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-604">line 604</a>
<a href="query-builder.js.html#sunlight-1-line-605">line 605</a>
</li>
</ul>
</dd>
@ -2997,7 +2997,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-427">line 427</a>
<a href="query-builder.js.html#sunlight-1-line-428">line 428</a>
</li>
</ul>
</dd>
@ -3176,7 +3176,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-680">line 680</a>
<a href="query-builder.js.html#sunlight-1-line-681">line 681</a>
</li>
</ul>
</dd>
@ -3402,7 +3402,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-440">line 440</a>
<a href="query-builder.js.html#sunlight-1-line-441">line 441</a>
</li>
</ul>
</dd>
@ -3593,7 +3593,7 @@
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-652">line 652</a>
<a href="query-builder.js.html#sunlight-1-line-653">line 653</a>
</li>
</ul>
</dd>
@ -3681,7 +3681,7 @@ prefixed with 'OR'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-705">line 705</a>
<a href="query-builder.js.html#sunlight-1-line-706">line 706</a>
</li>
</ul>
</dd>
@ -3866,7 +3866,7 @@ prefixed with 'OR'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-492">line 492</a>
<a href="query-builder.js.html#sunlight-1-line-493">line 493</a>
</li>
</ul>
</dd>
@ -4092,7 +4092,7 @@ prefixed with 'OR'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-453">line 453</a>
<a href="query-builder.js.html#sunlight-1-line-454">line 454</a>
</li>
</ul>
</dd>
@ -4180,7 +4180,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-717">line 717</a>
<a href="query-builder.js.html#sunlight-1-line-718">line 718</a>
</li>
</ul>
</dd>
@ -4406,7 +4406,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-466">line 466</a>
<a href="query-builder.js.html#sunlight-1-line-467">line 467</a>
</li>
</ul>
</dd>
@ -4591,7 +4591,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-518">line 518</a>
<a href="query-builder.js.html#sunlight-1-line-519">line 519</a>
</li>
</ul>
</dd>
@ -4750,7 +4750,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-542">line 542</a>
<a href="query-builder.js.html#sunlight-1-line-543">line 543</a>
</li>
</ul>
</dd>
@ -4909,7 +4909,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-566">line 566</a>
<a href="query-builder.js.html#sunlight-1-line-567">line 567</a>
</li>
</ul>
</dd>
@ -5048,7 +5048,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-371">line 371</a>
<a href="query-builder.js.html#sunlight-1-line-372">line 372</a>
</li>
</ul>
</dd>
@ -5230,7 +5230,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-578">line 578</a>
<a href="query-builder.js.html#sunlight-1-line-579">line 579</a>
</li>
</ul>
</dd>
@ -5440,7 +5440,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-806">line 806</a>
<a href="query-builder.js.html#sunlight-1-line-807">line 807</a>
</li>
</ul>
</dd>
@ -5625,7 +5625,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-506">line 506</a>
<a href="query-builder.js.html#sunlight-1-line-507">line 507</a>
</li>
</ul>
</dd>
@ -5784,7 +5784,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-530">line 530</a>
<a href="query-builder.js.html#sunlight-1-line-531">line 531</a>
</li>
</ul>
</dd>
@ -5943,7 +5943,7 @@ prefixed with 'OR NOT'</p>
<ul class="dummy">
<li>
<a href="query-builder.js.html">query-builder.js</a>,
<a href="query-builder.js.html#sunlight-1-line-554">line 554</a>
<a href="query-builder.js.html#sunlight-1-line-555">line 555</a>
</li>
</ul>
</dd>
@ -6007,7 +6007,7 @@ prefixed with 'OR NOT'</p>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Nov 4th 2014 using the <a
on Wed Nov 5th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>

View File

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

View File

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

View File

@ -76,11 +76,11 @@
class="sunlight-highlight-javascript linenums">"use strict";
/** @module node-query */
var nodeQuery = {};
var NodeQuery = function() {
var instance = null;
var instance = null;
/**
/**
* Create a query builder object
*
* @alias module:node-query
@ -89,7 +89,7 @@ var instance = null;
* @param {String} connLib - The name of the db connection library you are using, eg. mysql or mysql2
* @return {queryBuilder}
*/
nodeQuery.init = function (driverType, connObject, connLib) {
this.init = function (driverType, connObject, connLib) {
var fs = require('fs'),
qb = require('./query-builder');
@ -109,22 +109,26 @@ nodeQuery.init = function (driverType, connObject, connLib) {
instance = qb(require(paths.driver), require(paths.adapter)(connObject));
return instance;
};
};
/**
/**
* Return an existing query builder instance
*
* @return {queryBuilder}
*/
nodeQuery.getQuery = function () {
this.getQuery = function () {
if ( ! instance) {
throw new Error("No Query Builder instance to return");
}
return instance;
};
};
module.exports = nodeQuery;</pre>
module.exports = new NodeQuery();</pre>
</article>
</section>
@ -145,7 +149,7 @@ module.exports = nodeQuery;</pre>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Nov 4th 2014 using the <a
on Wed Nov 5th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>

View File

@ -280,8 +280,9 @@ var QueryBuilder = function(driver, adapter) {
lastItem = state.queryMap[state.queryMap.length - 1];
// Determine the correct conjunction
var conjunctionList = helpers.arrayPluck(state.queryMap, 'conjunction');
var conj = defaultConj;
if (state.queryMap.length === 0 || firstItem.conjunction.contains('JOIN'))
if (state.queryMap.length === 0 || ( ! helpers.regexInArray(conjunctionList, /^ ?WHERE/i)))
{
conj = " WHERE ";
}
@ -987,7 +988,7 @@ module.exports = QueryBuilder;</pre>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Tue Nov 4th 2014 using the <a
on Wed Nov 5th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>

View File

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