Update docs again

This commit is contained in:
Timothy Warren 2016-02-12 12:50:59 -05:00
parent 9c7b93e7e1
commit 508b1b0d88
6 changed files with 31 additions and 73 deletions

19
API.md
View File

@ -369,7 +369,6 @@ Returns **QueryBuilder** The Query Builder object, for chaining
## query ## query
Manually make an sql query Manually make an sql query
Returns a promise if no callback is provided
**Parameters** **Parameters**
@ -490,21 +489,3 @@ Set a 'where not in' clause
- `values` **Array** the array of items to search in - `values` **Array** the array of items to search in
Returns **QueryBuilder** The Query Builder object, for chaining Returns **QueryBuilder** The Query Builder object, for chaining
# promisify
Function to convert a callback function into a promise
**Parameters**
- `fn` **Function** the callback function to convert
**Examples**
```javascript
promisify(fs.readFile)('hello.txt', 'utf8')
.then(console.log)
.catch(console.error)
```
Returns **Promise** the new promise

View File

@ -237,11 +237,6 @@
class='regular block'> class='regular block'>
#whereNotIn #whereNotIn
</a> </a>
<a
href='#promisify'
class='block bold'>
promisify
</a>
</div> </div>
</div> </div>
</div> </div>
@ -1616,8 +1611,7 @@ prefixed with &apos;OR NOT&apos;</p>
#query<span class='gray'>(sql, [params], [callback])</span> #query<span class='gray'>(sql, [params], [callback])</span>
</code> </code>
<div class='force-inline'> <div class='force-inline'>
<p>Manually make an sql query <p>Manually make an sql query</p>
Returns a promise if no callback is provided</p>
</div> </div>
</a> </a>
@ -1626,8 +1620,7 @@ Returns a promise if no callback is provided</p>
<h2 id='QueryBuilder.query' class='mt0'> <h2 id='QueryBuilder.query' class='mt0'>
query<span class='gray'>(sql, [params], [callback])</span> query<span class='gray'>(sql, [params], [callback])</span>
</h2> </h2>
<p>Manually make an sql query <p>Manually make an sql query</p>
Returns a promise if no callback is provided</p>
<h4>Parameters</h4> <h4>Parameters</h4>
<ul class='suppress-p-margin'> <ul class='suppress-p-margin'>
@ -2032,34 +2025,6 @@ Returns a promise if no callback is provided</p>
</div> </div>
</div> </div>
</section> </section>
</div><div class='py1'><section class='py2 clearfix'>
<h2 id='promisify' class='mt0'>
promisify<span class='gray'>(fn)</span>
</h2>
<p>Function to convert a callback function into a promise</p>
<h4>Parameters</h4>
<ul class='suppress-p-margin'>
<li><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function">Function</a></code> <strong>fn</strong>
:
<div class='force-inline'>
<p>the callback function to convert</p>
</div>
</li>
</ul>
<h4>Returns</h4>
<code><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code></code>
:
<div class='force-inline'>
<p>the new promise</p>
</div>
<h4>Examples</h4>
<pre class='overflow-auto'>promisify(fs.readFile)(<span class="hljs-string">'hello.txt'</span>, <span class="hljs-string">'utf8'</span>)
.then(<span class="hljs-built_in">console</span>.log)
.catch(<span class="hljs-built_in">console</span>.error)</pre>
</section>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,17 +1,11 @@
'use strict'; 'use strict';
let getArgs = require('getargs'), const getArgs = require('getargs');
helpers = require('./helpers'), const helpers = require('./helpers');
State = require('./State'), const State = require('./State');
QueryParser = require('./QueryParser'); const QueryParser = require('./QueryParser');
/** class QueryBuilderBase {
* Main object that builds SQL queries.
*
* @param {Driver} Driver - The syntax driver for the database
* @param {Adapter} Adapter - The database module adapter for running queries
*/
class QueryBuilder {
/** /**
* @private * @private
* @constructor * @constructor
@ -290,6 +284,24 @@ class QueryBuilder {
_resetState() { _resetState() {
this.state = new State(); this.state = new State();
} }
}
/**
* Main object that builds SQL queries.
*
* @param {Driver} Driver - The syntax driver for the database
* @param {Adapter} Adapter - The database module adapter for running queries
*/
class QueryBuilder extends QueryBuilderBase {
/**
* @private
* @constructor
* @param {Driver} Driver - The syntax driver for the database
* @param {Adapter} Adapter - The database module adapter for running queries
*/
constructor(Driver, Adapter) {
super(Driver, Adapter);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// ! Miscellaneous Methods // ! Miscellaneous Methods
@ -297,7 +309,6 @@ class QueryBuilder {
/** /**
* Manually make an sql query * Manually make an sql query
* Returns a promise if no callback is provided
* *
* @param {string} sql - The sql to execute * @param {string} sql - The sql to execute
* @param {array} [params] - The query parameters * @param {array} [params] - The query parameters

View File

@ -5,7 +5,7 @@
* *
* @module drivers/sqlite * @module drivers/sqlite
*/ */
module.exports = (function() { module.exports = (() => {
delete require.cache[require.resolve('../Driver')]; delete require.cache[require.resolve('../Driver')];
let driver = require('../Driver'); let driver = require('../Driver');
@ -20,7 +20,7 @@ module.exports = (function() {
* @param {Array} [data] - The array of object containing data to insert * @param {Array} [data] - The array of object containing data to insert
* @return {String} - The generated sql statement * @return {String} - The generated sql statement
*/ */
driver.insertBatch = function(table, data) { driver.insertBatch = (table, data) => {
// Get the data values to insert, so they can // Get the data values to insert, so they can
// be parameterized // be parameterized
@ -63,4 +63,4 @@ module.exports = (function() {
}; };
return driver; return driver;
}()); })();

View File

@ -4,6 +4,7 @@
/** /**
* Function to convert a callback function into a promise * Function to convert a callback function into a promise
* *
* @private
* @see http://eddmann.com/posts/promisifying-error-first-asynchronous-callbacks-in-javascript/ * @see http://eddmann.com/posts/promisifying-error-first-asynchronous-callbacks-in-javascript/
* @example promisify(fs.readFile)('hello.txt', 'utf8') * @example promisify(fs.readFile)('hello.txt', 'utf8')
* .then(console.log) * .then(console.log)