From 508b1b0d881c772bc871a0223ac9f2118e30e9f3 Mon Sep 17 00:00:00 2001
From: Timothy J Warren
Date: Fri, 12 Feb 2016 12:50:59 -0500
Subject: [PATCH] Update docs again
---
API.md | 19 -------------------
docs/index.html | 39 ++-------------------------------------
lib/QueryBuilder.js | 35 +++++++++++++++++++++++------------
lib/drivers/Sqlite.js | 6 +++---
lib/helpers.js | 2 +-
lib/promisify.js | 3 ++-
6 files changed, 31 insertions(+), 73 deletions(-)
diff --git a/API.md b/API.md
index 7885a1c..157504b 100644
--- a/API.md
+++ b/API.md
@@ -369,7 +369,6 @@ Returns **QueryBuilder** The Query Builder object, for chaining
## query
Manually make an sql query
-Returns a promise if no callback is provided
**Parameters**
@@ -490,21 +489,3 @@ Set a 'where not in' clause
- `values` **Array** the array of items to search in
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
diff --git a/docs/index.html b/docs/index.html
index 7621d25..c781fdc 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -237,11 +237,6 @@
class='regular block'>
#whereNotIn
-
- promisify
-
@@ -1616,8 +1611,7 @@ prefixed with 'OR NOT'
#query(sql, [params], [callback])
-
Manually make an sql query
-Returns a promise if no callback is provided
+
Manually make an sql query
@@ -1626,8 +1620,7 @@ Returns a promise if no callback is provided
query(sql, [params], [callback])
- Manually make an sql query
- Returns a promise if no callback is provided
+ Manually make an sql query
Parameters
@@ -2032,34 +2025,6 @@ Returns a promise if no callback is provided
-
-
- promisify(fn)
-
- Function to convert a callback function into a promise
-
- Parameters
-
- Function
fn
- :
-
-
the callback function to convert
-
-
-
-
- Returns
- Promise
- :
-
- Examples
-promisify(fs.readFile)('hello.txt', 'utf8')
-.then(console.log)
-.catch(console.error)
-
diff --git a/lib/QueryBuilder.js b/lib/QueryBuilder.js
index 6051d60..bc1865b 100755
--- a/lib/QueryBuilder.js
+++ b/lib/QueryBuilder.js
@@ -1,17 +1,11 @@
'use strict';
-let getArgs = require('getargs'),
- helpers = require('./helpers'),
- State = require('./State'),
- QueryParser = require('./QueryParser');
+const getArgs = require('getargs');
+const helpers = require('./helpers');
+const State = require('./State');
+const QueryParser = require('./QueryParser');
-/**
- * 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 {
+class QueryBuilderBase {
/**
* @private
* @constructor
@@ -290,6 +284,24 @@ class QueryBuilder {
_resetState() {
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
@@ -297,7 +309,6 @@ class QueryBuilder {
/**
* Manually make an sql query
- * Returns a promise if no callback is provided
*
* @param {string} sql - The sql to execute
* @param {array} [params] - The query parameters
diff --git a/lib/drivers/Sqlite.js b/lib/drivers/Sqlite.js
index d2110d9..6a7e6a3 100644
--- a/lib/drivers/Sqlite.js
+++ b/lib/drivers/Sqlite.js
@@ -5,7 +5,7 @@
*
* @module drivers/sqlite
*/
-module.exports = (function() {
+module.exports = (() => {
delete require.cache[require.resolve('../Driver')];
let driver = require('../Driver');
@@ -20,7 +20,7 @@ module.exports = (function() {
* @param {Array} [data] - The array of object containing data to insert
* @return {String} - The generated sql statement
*/
- driver.insertBatch = function(table, data) {
+ driver.insertBatch = (table, data) => {
// Get the data values to insert, so they can
// be parameterized
@@ -63,4 +63,4 @@ module.exports = (function() {
};
return driver;
-}());
\ No newline at end of file
+})();
\ No newline at end of file
diff --git a/lib/helpers.js b/lib/helpers.js
index f59bf8d..adc9c2b 100755
--- a/lib/helpers.js
+++ b/lib/helpers.js
@@ -133,7 +133,7 @@ types.forEach(t => {
* @param {mixed} o - The object to check its type
* @return {Boolean} - If the type matches
*/
- helpers[`is${t}`] = function(o) {
+ helpers[`is${t}`] = function (o) {
if (t.toLowerCase() === 'infinite') {
t = 'infinity';
}
diff --git a/lib/promisify.js b/lib/promisify.js
index 8fa72b5..1079b49 100644
--- a/lib/promisify.js
+++ b/lib/promisify.js
@@ -4,6 +4,7 @@
/**
* Function to convert a callback function into a promise
*
+ * @private
* @see http://eddmann.com/posts/promisifying-error-first-asynchronous-callbacks-in-javascript/
* @example promisify(fs.readFile)('hello.txt', 'utf8')
* .then(console.log)
@@ -14,7 +15,7 @@
function promisify(fn) {
return function () {
let args = [].slice.call(arguments);
- return new Promise(function(resolve, reject) {
+ return new Promise(function (resolve, reject) {
fn.apply(undefined, args.concat((error, value) => {
return error ? reject(error) : resolve(value);
}));