node-query/documentation/QueryBuilder.html

8096 lines
93 KiB
HTML
Raw Permalink Normal View History

2018-02-12 14:58:50 -05:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: QueryBuilder</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: QueryBuilder</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>QueryBuilder<span class="signature">(Driver, Adapter)</span><span class="type-signature"></span></h2>
<div class="class-description">Main object that builds SQL queries.</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="QueryBuilder"><span class="type-signature"></span>new QueryBuilder<span class="signature">(Driver, Adapter)</span><span class="type-signature"></span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>Driver</code></td>
<td class="type">
<span class="param-type">Driver</span>
</td>
<td class="description last">The syntax driver for the database</td>
</tr>
<tr>
<td class="name"><code>Adapter</code></td>
<td class="type">
<span class="param-type"><a href="Adapter.html">Adapter</a></span>
</td>
<td class="description last">The database module adapter for running queries</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line11">line 11</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Extends</h3>
<ul>
<li>QueryBuilderBase</li>
</ul>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="delete"><span class="type-signature"></span>delete<span class="signature">(table, where<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="Result.html">Result</a>>}</span></h4>
<div class="description">
Run the generated delete query
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</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="attributes">
</td>
<td class="description last">The table to insert into</td>
</tr>
<tr>
<td class="name"><code>where</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">Where clause for delete statement</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line595">line 595</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- Promise containing the result of the query
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;<a href="Result.html">Result</a>></span>
</dd>
</dl>
<h4 class="name" id="end"><span class="type-signature"></span>end<span class="signature">()</span><span class="type-signature"> &rarr; {void}</span></h4>
<div class="description">
Closes the database connection for the current adapter
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line81">line 81</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">void</span>
</dd>
</dl>
<h4 class="name" id="from"><span class="type-signature"></span>from<span class="signature">(tableName)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Specify the database table to select from
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>tableName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The table to use for the current query</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line132">line 132</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h5>Examples</h5>
<pre class="prettyprint"><code>query.from('tableName');</code></pre>
<pre class="prettyprint"><code>query.from('tableName t'); // Select the table with an alias</code></pre>
<h4 class="name" id="get"><span class="type-signature"></span>get<span class="signature">(table<span class="signature-attributes">opt</span>, limit<span class="signature-attributes">opt</span>, offset<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="Result.html">Result</a>>}</span></h4>
<div class="description">
Get the results of the compiled query
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</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="attributes">
&lt;optional><br>
</td>
<td class="description last">The table to select from</td>
</tr>
<tr>
<td class="name"><code>limit</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">A limit for the query</td>
</tr>
<tr>
<td class="name"><code>offset</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">An offset for the query</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line513">line 513</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- Promise containing the result of the query
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;<a href="Result.html">Result</a>></span>
</dd>
</dl>
<h5>Examples</h5>
<pre class="prettyprint"><code>query.get('table_name').then(promiseCallback); // Get all the rows in the table</code></pre>
<pre class="prettyprint"><code>query.get('table_name', 5); // Get 5 rows from the table</code></pre>
<pre class="prettyprint"><code>query.get(); // Get the results of a query generated with other methods</code></pre>
<h4 class="name" id="getCompiledDelete"><span class="type-signature"></span>getCompiledDelete<span class="signature">(table, reset<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {String}</span></h4>
<div class="description">
Return generated delete query SQL
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</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="attributes">
</td>
<td class="default">
</td>
<td class="description last">the name of the table to delete from</td>
</tr>
<tr>
<td class="name"><code>reset</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
true
</td>
<td class="description last">Whether to reset the query builder so another query can be built</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line652">line 652</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The compiled sql statement
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
<h4 class="name" id="getCompiledInsert"><span class="type-signature"></span>getCompiledInsert<span class="signature">(table, reset<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {String}</span></h4>
<div class="description">
Return generated insert query SQL
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</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="attributes">
</td>
<td class="default">
</td>
<td class="description last">the name of the table to insert into</td>
</tr>
<tr>
<td class="name"><code>reset</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
true
</td>
<td class="description last">Whether to reset the query builder so another query can be built</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line630">line 630</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The compiled sql statement
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
<h4 class="name" id="getCompiledSelect"><span class="type-signature"></span>getCompiledSelect<span class="signature">(table<span class="signature-attributes">opt</span>, reset<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {String}</span></h4>
<div class="description">
Return generated select query SQL
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</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="attributes">
&lt;optional><br>
</td>
<td class="default">
</td>
<td class="description last">the name of the table to retrieve from</td>
</tr>
<tr>
<td class="name"><code>reset</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
true
</td>
<td class="description last">Whether to reset the query builder so another query can be built</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line615">line 615</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The compiled sql statement
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
<h4 class="name" id="getCompiledUpdate"><span class="type-signature"></span>getCompiledUpdate<span class="signature">(table, reset<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {String}</span></h4>
<div class="description">
Return generated update query SQL
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</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="attributes">
</td>
<td class="default">
</td>
<td class="description last">the name of the table to update</td>
</tr>
<tr>
<td class="name"><code>reset</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
true
</td>
<td class="description last">Whether to reset the query builder so another query can be built</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line641">line 641</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The compiled sql statement
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
<h4 class="name" id="groupBy"><span class="type-signature"></span>groupBy<span class="signature">(field)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Group the results by the selected field(s)
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>field</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">Array</span>
</td>
<td class="description last">The name of the field to group by</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line396">line 396</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="groupEnd"><span class="type-signature"></span>groupEnd<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Ends a logical grouping started with one of the groupStart methods
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line492">line 492</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="groupStart"><span class="type-signature"></span>groupStart<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Adds an open paren to the current query for logical grouping
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line456">line 456</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="having"><span class="type-signature"></span>having<span class="signature">(key, val<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Add a 'having' clause
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The name of the field and the comparision operator, or an object</td>
</tr>
<tr>
<td class="name"><code>val</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">Number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
null
</td>
<td class="description last">The value to compare if the value of key is a string</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line205">line 205</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="insert"><span class="type-signature"></span>insert<span class="signature">(table, data<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="Result.html">Result</a>>}</span></h4>
<div class="description">
Run the generated insert query
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</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="attributes">
</td>
<td class="description last">The table to insert into</td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">Data to insert, if not already added with the 'set' method</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line533">line 533</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- Promise containing the result of the query
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;<a href="Result.html">Result</a>></span>
</dd>
</dl>
<h4 class="name" id="insertBatch"><span class="type-signature"></span>insertBatch<span class="signature">(table, data)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="Result.html">Result</a>>}</span></h4>
<div class="description">
Insert multiple sets of rows at a time
</div>
<h5>Parameters:</h5>
<table class="params">
<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">The table to insert into</td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">The array of objects containing data rows to insert</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line551">line 551</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- Promise containing the result of the query
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;<a href="Result.html">Result</a>></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}])
.then(promiseCallback);</code></pre>
<h4 class="name" id="join"><span class="type-signature"></span>join<span class="signature">(table, cond, type<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Add a join clause to the query
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</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="attributes">
</td>
<td class="default">
</td>
<td class="description last">The table you are joining</td>
</tr>
<tr>
<td class="name"><code>cond</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The join condition.</td>
</tr>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
'inner'
</td>
<td class="description last">The type of join, which defaults to inner</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line371">line 371</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="like"><span class="type-signature"></span>like<span class="signature">(field, val, pos<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Add a 'like/ and like' clause to the query
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>field</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The name of the field to compare to</td>
</tr>
<tr>
<td class="name"><code>val</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The value to compare to</td>
</tr>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
both
</td>
<td class="description last">The placement of the wildcard character(s): before, after, or both</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line154">line 154</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="limit"><span class="type-signature"></span>limit<span class="signature">(limit, offset<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Put a limit on the query
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>limit</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
</td>
<td class="description last">The maximum number of rows to fetch</td>
</tr>
<tr>
<td class="name"><code>offset</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">The row number to start from</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line444">line 444</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="notLike"><span class="type-signature"></span>notLike<span class="signature">(field, val, pos<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Add a 'not like/ and not like' clause to the query
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>field</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The name of the field to compare to</td>
</tr>
<tr>
<td class="name"><code>val</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The value to compare to</td>
</tr>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
both
</td>
<td class="description last">The placement of the wildcard character(s): before, after, or both</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line167">line 167</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="orderBy"><span class="type-signature"></span>orderBy<span class="signature">(field, type<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Order the results by the selected field(s)
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>field</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The field(s) to order by</td>
</tr>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
'ASC'
</td>
<td class="description last">The order direction, ASC or DESC</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line416">line 416</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="orGroupStart"><span class="type-signature"></span>orGroupStart<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Adds an open paren to the current query for logical grouping,
prefixed with 'OR'
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line469">line 469</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="orHaving"><span class="type-signature"></span>orHaving<span class="signature">(key, val<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Add an 'or having' clause
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The name of the field and the comparision operator, or an object</td>
</tr>
<tr>
<td class="name"><code>val</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">Number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
null
</td>
<td class="description last">The value to compare if the value of key is a string</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line217">line 217</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="orLike"><span class="type-signature"></span>orLike<span class="signature">(field, val, pos<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Add an 'or like' clause to the query
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>field</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The name of the field to compare to</td>
</tr>
<tr>
<td class="name"><code>val</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The value to compare to</td>
</tr>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
both
</td>
<td class="description last">The placement of the wildcard character(s): before, after, or both</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line180">line 180</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="orNotGroupStart"><span class="type-signature"></span>orNotGroupStart<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Adds an open paren to the current query for logical grouping,
prefixed with 'OR NOT'
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line481">line 481</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="orNotLike"><span class="type-signature"></span>orNotLike<span class="signature">(field, val, pos<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Add an 'or not like' clause to the query
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>field</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The name of the field to compare to</td>
</tr>
<tr>
<td class="name"><code>val</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The value to compare to</td>
</tr>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
both
</td>
<td class="description last">The placement of the wildcard character(s): before, after, or both</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line193">line 193</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="orWhere"><span class="type-signature"></span>orWhere<span class="signature">(key, val<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Set a 'or where' clause
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">The name of the field and the comparision operator, or an object</td>
</tr>
<tr>
<td class="name"><code>val</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">Number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">The value to compare if the value of key is a string</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line241">line 241</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="orWhereIn"><span class="type-signature"></span>orWhereIn<span class="signature">(key, values)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Set a 'or where in' clause
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">the field to search</td>
</tr>
<tr>
<td class="name"><code>values</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">the array of items to search in</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line309">line 309</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="orWhereIsNotNull"><span class="type-signature"></span>orWhereIsNotNull<span class="signature">(field)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Field is not null prefixed with 'OR'
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>field</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name of the field</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line285">line 285</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="orWhereIsNull"><span class="type-signature"></span>orWhereIsNull<span class="signature">(field)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Field is null prefixed with 'OR'
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>field</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name of the field</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line274">line 274</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="orWhereNotIn"><span class="type-signature"></span>orWhereNotIn<span class="signature">(key, values)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Set a 'or where not in' clause
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">the field to search</td>
</tr>
<tr>
<td class="name"><code>values</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">the array of items to search in</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line333">line 333</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="query"><span class="type-signature"></span>query<span class="signature">(sql, params<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Run an arbitrary sql query. Run as a prepared statement.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>sql</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="description last">The sql to execute</td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">The query parameters</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line43">line 43</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- Promise with result of query
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="queryFile"><span class="type-signature"></span>queryFile<span class="signature">(file, separator<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Run a set of queries from a file
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>file</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The path to the sql file</td>
</tr>
<tr>
<td class="name"><code>separator</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
';'
</td>
<td class="description last">The character separating each query</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line23">line 23</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The result of all the queries
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="resetQuery"><span class="type-signature"></span>resetQuery<span class="signature">()</span><span class="type-signature"> &rarr; {void}</span></h4>
<div class="description">
Reset the object state for a new query
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line52">line 52</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">void</span>
</dd>
</dl>
<h4 class="name" id="select"><span class="type-signature"></span>select<span class="signature">(fields)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Specify rows to select in the query
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>fields</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">Array</span>
</td>
<td class="description last">The fields to select from the current table</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line97">line 97</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h5>Examples</h5>
<pre class="prettyprint"><code>query.select('foo, bar'); // Select multiple fields with a string</code></pre>
<pre class="prettyprint"><code>query.select(['foo', 'bar']); // Select multiple fileds with an array</code></pre>
<h4 class="name" id="set"><span class="type-signature"></span>set<span class="signature">(key, val<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Set values for insertion or updating
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">The key or object to use</td>
</tr>
<tr>
<td class="name"><code>val</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">The value if using a scalar key</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line347">line 347</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h5>Examples</h5>
<pre class="prettyprint"><code>query.set('foo', 'bar'); // Set a key, value pair</code></pre>
<pre class="prettyprint"><code>query.set({foo:'bar'}); // Set with an object</code></pre>
<h4 class="name" id="truncate"><span class="type-signature"></span>truncate<span class="signature">(table)</span><span class="type-signature"> &rarr; {void|Promise}</span></h4>
<div class="description">
Empties the selected database table
</div>
<h5>Parameters:</h5>
<table class="params">
<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">the name of the table to truncate</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line72">line 72</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- Returns a promise if no callback is supplied
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">void</span>
|
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="update"><span class="type-signature"></span>update<span class="signature">(table, data<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="Result.html">Result</a>>}</span></h4>
<div class="description">
Run the generated update query
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</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="attributes">
</td>
<td class="description last">The table to insert into</td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">Data to insert, if not already added with the 'set' method</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line565">line 565</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- Promise containing the result of the query
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;<a href="Result.html">Result</a>></span>
</dd>
</dl>
<h4 class="name" id="updateBatch"><span class="type-signature"></span>updateBatch<span class="signature">(table, data, updateKey)</span><span class="type-signature"> &rarr; {Number}</span></h4>
<div class="description">
Creates a batch update sql statement
</div>
<h5>Parameters:</h5>
<table class="params">
<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">The table to update</td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Batch insert data</td>
</tr>
<tr>
<td class="name"><code>updateKey</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The field in the table to compare against for updating</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line582">line 582</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Number of rows updated
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="where"><span class="type-signature"></span>where<span class="signature">(key, val<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Set a 'where' clause
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">The name of the field and the comparision operator, or an object</td>
</tr>
<tr>
<td class="name"><code>val</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">Number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">The value to compare if the value of key is a string</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line229">line 229</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="whereIn"><span class="type-signature"></span>whereIn<span class="signature">(key, values)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Set a 'where in' clause
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">the field to search</td>
</tr>
<tr>
<td class="name"><code>values</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">the array of items to search in</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line297">line 297</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="whereIsNotNull"><span class="type-signature"></span>whereIsNotNull<span class="signature">(field)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Specify that a field IS NOT NULL
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>field</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name so the field that is not to be null</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line263">line 263</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="whereIsNull"><span class="type-signature"></span>whereIsNull<span class="signature">(field)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Select a field that is Null
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>field</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The name of the field that has a NULL value</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line252">line 252</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
<h4 class="name" id="whereNotIn"><span class="type-signature"></span>whereNotIn<span class="signature">(key, values)</span><span class="type-signature"> &rarr; {<a href="QueryBuilder.html">QueryBuilder</a>}</span></h4>
<div class="description">
Set a 'where not in' clause
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">the field to search</td>
</tr>
<tr>
<td class="name"><code>values</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">the array of items to search in</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="QueryBuilder.js.html">QueryBuilder.js</a>, <a href="QueryBuilder.js.html#line321">line 321</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- The Query Builder object, for chaining
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="QueryBuilder.html">QueryBuilder</a></span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-drivers_MariaDB.html">drivers/MariaDB</a></li><li><a href="module-drivers_MSSQLDriver.html">drivers/MSSQLDriver</a></li><li><a href="module-drivers_Mysql.html">drivers/Mysql</a></li><li><a href="module-drivers_Pg.html">drivers/Pg</a></li><li><a href="module-drivers_Sqlite.html">drivers/Sqlite</a></li></ul><h3>Classes</h3><ul><li><a href="NodeQuery.html">NodeQuery</a></li><li><a href="QueryBuilder.html">QueryBuilder</a></li><li><a href="Result.html">Result</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Feb 12 2018 14:58:25 GMT-0500 (EST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>