Browse Source

Merge branch 'develop'

Timothy J. Warren 1 year ago
parent
commit
cc6a3bb80b
78 changed files with 5854 additions and 4492 deletions
  1. 29
    0
      .editorconfig
  2. 4
    1
      .gitignore
  3. 31
    0
      .gitlab-ci.yml
  4. 9
    0
      .istanbul.yml
  5. 0
    7
      .jscsrc
  6. 233
    240
      API.md
  7. 5
    1
      CHANGELOG.md
  8. 6
    13
      README.md
  9. 12
    0
      docs/assets/bass-addons.css
  10. 379
    686
      docs/assets/bass.css
  11. BIN
      docs/assets/fonts/EOT/SourceCodePro-Bold.eot
  12. BIN
      docs/assets/fonts/EOT/SourceCodePro-Regular.eot
  13. 93
    0
      docs/assets/fonts/LICENSE.txt
  14. BIN
      docs/assets/fonts/OTF/SourceCodePro-Bold.otf
  15. BIN
      docs/assets/fonts/OTF/SourceCodePro-Regular.otf
  16. BIN
      docs/assets/fonts/TTF/SourceCodePro-Bold.ttf
  17. BIN
      docs/assets/fonts/TTF/SourceCodePro-Regular.ttf
  18. BIN
      docs/assets/fonts/WOFF/OTF/SourceCodePro-Bold.otf.woff
  19. BIN
      docs/assets/fonts/WOFF/OTF/SourceCodePro-Regular.otf.woff
  20. BIN
      docs/assets/fonts/WOFF/TTF/SourceCodePro-Bold.ttf.woff
  21. BIN
      docs/assets/fonts/WOFF/TTF/SourceCodePro-Regular.ttf.woff
  22. BIN
      docs/assets/fonts/WOFF2/OTF/SourceCodePro-Bold.otf.woff2
  23. BIN
      docs/assets/fonts/WOFF2/OTF/SourceCodePro-Regular.otf.woff2
  24. BIN
      docs/assets/fonts/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2
  25. BIN
      docs/assets/fonts/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2
  26. 23
    0
      docs/assets/fonts/source-code-pro.css
  27. 89
    21
      docs/assets/site.js
  28. 88
    47
      docs/assets/style.css
  29. 3660
    2132
      docs/index.html
  30. 0
    87
      gulpfile.js
  31. 9
    11
      lib/Adapter.js
  32. 31
    34
      lib/Driver.js
  33. 10
    10
      lib/NodeQuery.js
  34. 79
    402
      lib/QueryBuilder.js
  35. 272
    0
      lib/QueryBuilderBase.js
  36. 14
    14
      lib/QueryParser.js
  37. 10
    10
      lib/Result.js
  38. 1
    3
      lib/State.js
  39. 8
    0
      lib/adapters/Firebird/index.js
  40. 61
    0
      lib/adapters/Firebird/node-firebird.js
  41. 0
    0
      lib/adapters/MSSQLServer/index.js
  42. 3
    0
      lib/adapters/MariaDB/index.js
  43. 0
    71
      lib/adapters/Mysql.js
  44. 7
    0
      lib/adapters/Mysql/index.js
  45. 52
    0
      lib/adapters/Mysql/mysql2.js
  46. 18
    28
      lib/adapters/Pg/Pg.js
  47. 7
    0
      lib/adapters/Pg/index.js
  48. 0
    64
      lib/adapters/Sqlite.js
  49. 67
    0
      lib/adapters/Sqlite/dblite.js
  50. 10
    0
      lib/adapters/Sqlite/index.js
  51. 63
    0
      lib/adapters/Sqlite/sqlite3.js
  52. 45
    0
      lib/drivers/Firebird.js
  53. 8
    0
      lib/drivers/MariaDB.js
  54. 9
    10
      lib/drivers/Mysql.js
  55. 2
    2
      lib/drivers/Pg.js
  56. 9
    11
      lib/drivers/Sqlite.js
  57. 10
    11
      lib/helpers.js
  58. 31
    23
      package.json
  59. 0
    5
      sonar-project.properties
  60. BIN
      test/FB_TEST_DB.FDB
  61. 38
    0
      test/adapters/00node-firebird_test.js
  62. 14
    64
      test/adapters/dblite_test.js
  63. 14
    60
      test/adapters/mysql2_test.js
  64. 22
    53
      test/adapters/pg_test.js
  65. 63
    0
      test/adapters/sqlite3_test.js
  66. 2
    3
      test/base.js
  67. 0
    230
      test/base/adapterCallbackTestRunner.js
  68. 21
    21
      test/base/adapterPromiseTestRunner.js
  69. 50
    51
      test/base/tests.js
  70. 8
    7
      test/base_test.js
  71. 39
    0
      test/config-ci.json
  72. 16
    0
      test/docker_install.sh
  73. 14
    14
      test/helpers_test.js
  74. 1
    1
      test/mocha.opts
  75. 34
    39
      test/query-parser_test.js
  76. 15
    0
      test/sql/mssql.sql
  77. 2
    3
      test/sql/mysql.sql
  78. 4
    2
      test/sql/pgsql.sql

+ 29
- 0
.editorconfig View File

@@ -0,0 +1,29 @@
1
+# EditorConfig is awesome: http://EditorConfig.org
2
+
3
+# top-most EditorConfig file
4
+root = true
5
+
6
+# Unix-style newlines with a newline ending every file
7
+[*]
8
+end_of_line = lf
9
+insert_final_newline = true
10
+
11
+# Matches multiple files with brace expansion notation
12
+# Set default charset
13
+[*]
14
+charset = utf-8
15
+
16
+# Tab indentation (no size specified)
17
+[*]
18
+indent_style = tab
19
+indent_size = 4
20
+
21
+# Indentation override for all JS under lib directory
22
+[*.js]
23
+indent_size = 2
24
+
25
+# Matches the exact files either package.json or .travis.yml
26
+[*.yml]
27
+indent_style = space
28
+indent_size = 2
29
+

+ 4
- 1
.gitignore View File

@@ -3,4 +3,7 @@ coverage
3 3
 npm-debug.log
4 4
 node_modules/*
5 5
 .sonar/*
6
-test/config.json
6
+test/config.json
7
+.DS_store
8
+/.idea/
9
+yarn.lock

+ 31
- 0
.gitlab-ci.yml View File

@@ -0,0 +1,31 @@
1
+before_script:
2
+    # Install dependencies
3
+    - bash test/docker_install.sh > /dev/null
4
+    - npm install
5
+
6
+services:
7
+  - mysql:latest
8
+  - postgres:latest
9
+
10
+variables:
11
+    MYSQL_ROOT_PASSWORD: foo-bar-baz
12
+    MYSQL_DATABASE: test
13
+    MYSQL_USER: test
14
+    MYSQL_PASSWORD: test
15
+    POSTGRES_DB: test
16
+    POSTGRES_USER: test
17
+    POSTGRES_PASSWORD: test
18
+
19
+# This folder is cached between builds
20
+# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
21
+cache:
22
+  paths:
23
+  - node_modules/
24
+
25
+test:6:
26
+  image: node:6
27
+  script: npm run test
28
+
29
+test:latest:
30
+  image: node:latest
31
+  script: npm run test

+ 9
- 0
.istanbul.yml View File

@@ -0,0 +1,9 @@
1
+reporting:
2
+    print: summary
3
+    reports:
4
+        - lcov
5
+        - lcovonly
6
+        - clover
7
+        - html
8
+        - text
9
+    dir: ./coverage

+ 0
- 7
.jscsrc View File

@@ -1,7 +0,0 @@
1
-{
2
-	"preset": "airbnb",
3
-	"validateIndentation": null,
4
-	"requireLineFeedAtFileEnd": null,
5
-	"disallowSpaceAfterPrefixUnaryOperators": null,
6
-	"disallowMultipleVarDecl": null
7
-}

+ 233
- 240
API.md View File

@@ -1,10 +1,12 @@
1
+<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
2
+
1 3
 # NodeQuery
2 4
 
3 5
 Class for connection management
4 6
 
5 7
 **Parameters**
6 8
 
7
--   `config` **object** connection parameters
9
+-   `config` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** connection parameters
8 10
 
9 11
 ## constructor
10 12
 
@@ -12,7 +14,7 @@ Constructor
12 14
 
13 15
 **Parameters**
14 16
 
15
--   `config` **object** connection parameters
17
+-   `config` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** connection parameters
16 18
 
17 19
 **Examples**
18 20
 
@@ -39,10 +41,12 @@ let nodeQuery = require('ci-node-query')({
39 41
 
40 42
 Return an existing query builder instance
41 43
 
42
-Returns **QueryBuilder** The Query Builder object
44
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object
43 45
 
44 46
 # QueryBuilder
45 47
 
48
+**Extends QueryBuilderBase**
49
+
46 50
 Main object that builds SQL queries.
47 51
 
48 52
 **Parameters**
@@ -50,17 +54,32 @@ Main object that builds SQL queries.
50 54
 -   `Driver` **Driver** The syntax driver for the database
51 55
 -   `Adapter` **Adapter** The database module adapter for running queries
52 56
 
53
-## delete
57
+## query
54 58
 
55
-Run the generated delete query
59
+Run an arbitrary sql query. Run as a prepared statement.
60
+
61
+**Parameters**
62
+
63
+-   `sql` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The sql to execute
64
+-   `params` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)]** The query parameters
65
+
66
+Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** Promise with result of query
67
+
68
+## resetQuery
69
+
70
+Reset the object state for a new query
71
+
72
+Returns **void** 
73
+
74
+## truncate
75
+
76
+Empties the selected database table
56 77
 
57 78
 **Parameters**
58 79
 
59
--   `table` **String** The table to insert into
60
--   `where` **[Object]** Where clause for delete statement
61
--   `callback` **[Function]** Callback for handling response from the database
80
+-   `table` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the table to truncate
62 81
 
63
-Returns **void or Promise** If no callback is passed, a promise is returned
82
+Returns **(void | [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise))** Returns a promise if no callback is supplied
64 83
 
65 84
 ## end
66 85
 
@@ -68,394 +87,367 @@ Closes the database connection for the current adapter
68 87
 
69 88
 Returns **void** 
70 89
 
71
-## from
90
+## select
72 91
 
73
-Specify the database table to select from
92
+Specify rows to select in the query
74 93
 
75 94
 **Parameters**
76 95
 
77
--   `tableName` **String** The table to use for the current query
96
+-   `fields` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array))** The fields to select from the current table
78 97
 
79 98
 **Examples**
80 99
 
81 100
 ```javascript
82
-query.from('tableName');
101
+query.select('foo, bar'); // Select multiple fields with a string
83 102
 ```
84 103
 
85 104
 ```javascript
86
-query.from('tableName t'); // Select the table with an alias
105
+query.select(['foo', 'bar']); // Select multiple fileds with an array
87 106
 ```
88 107
 
89
-Returns **QueryBuilder** The Query Builder object, for chaining
108
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
90 109
 
91
-## get
110
+## from
92 111
 
93
-Get the results of the compiled query
112
+Specify the database table to select from
94 113
 
95 114
 **Parameters**
96 115
 
97
--   `table` **[String]** The table to select from
98
--   `limit` **[Number]** A limit for the query
99
--   `offset` **[Number]** An offset for the query
100
--   `callback` **[Function]** A callback for receiving the result
116
+-   `tableName` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The table to use for the current query
101 117
 
102 118
 **Examples**
103 119
 
104 120
 ```javascript
105
-query.get('table_name').then(promiseCallback); // Get all the rows in the table
106
-```
107
-
108
-```javascript
109
-query.get('table_name', 5, callback); // Get 5 rows from the table
121
+query.from('tableName');
110 122
 ```
111 123
 
112 124
 ```javascript
113
-query.get(callback); // Get the results of a query generated with other methods
125
+query.from('tableName t'); // Select the table with an alias
114 126
 ```
115 127
 
116
-Returns **void or Promise** If no callback is passed, a promise is returned
128
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
117 129
 
118
-## getCompiledDelete
130
+## like
119 131
 
120
-Return generated delete query SQL
132
+Add a 'like/ and like' clause to the query
121 133
 
122 134
 **Parameters**
123 135
 
124
--   `table` **String** the name of the table to delete from
125
--   `reset` **[Boolean]** Whether to reset the query builder so another query can be built (optional, default `true`)
136
+-   `field` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the field  to compare to
137
+-   `val` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The value to compare to
138
+-   `pos` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The placement of the wildcard character(s): before, after, or both (optional, default `both`)
126 139
 
127
-Returns **String** The compiled sql statement
140
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
128 141
 
129
-## getCompiledInsert
142
+## notLike
130 143
 
131
-Return generated insert query SQL
144
+Add a 'not like/ and not like' clause to the query
132 145
 
133 146
 **Parameters**
134 147
 
135
--   `table` **String** the name of the table to insert into
136
--   `reset` **[Boolean]** Whether to reset the query builder so another query can be built (optional, default `true`)
148
+-   `field` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the field  to compare to
149
+-   `val` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The value to compare to
150
+-   `pos` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The placement of the wildcard character(s): before, after, or both (optional, default `both`)
137 151
 
138
-Returns **String** The compiled sql statement
152
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
139 153
 
140
-## getCompiledSelect
154
+## orLike
141 155
 
142
-Return generated select query SQL
156
+Add an 'or like' clause to the query
143 157
 
144 158
 **Parameters**
145 159
 
146
--   `table` **[String]** the name of the table to retrieve from
147
--   `reset` **[Boolean]** Whether to reset the query builder so another query can be built (optional, default `true`)
160
+-   `field` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the field  to compare to
161
+-   `val` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The value to compare to
162
+-   `pos` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The placement of the wildcard character(s): before, after, or both (optional, default `both`)
148 163
 
149
-Returns **String** The compiled sql statement
164
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
150 165
 
151
-## getCompiledUpdate
166
+## orNotLike
152 167
 
153
-Return generated update query SQL
168
+Add an 'or not like' clause to the query
154 169
 
155 170
 **Parameters**
156 171
 
157
--   `table` **String** the name of the table to update
158
--   `reset` **[Boolean]** Whether to reset the query builder so another query can be built (optional, default `true`)
172
+-   `field` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the field  to compare to
173
+-   `val` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The value to compare to
174
+-   `pos` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The placement of the wildcard character(s): before, after, or both (optional, default `both`)
159 175
 
160
-Returns **String** The compiled sql statement
176
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
161 177
 
162
-## groupBy
178
+## having
163 179
 
164
-Group the results by the selected field(s)
180
+Add a 'having' clause
165 181
 
166 182
 **Parameters**
167 183
 
168
--   `field` **String or Array** The name of the field to group by
169
-
170
-Returns **QueryBuilder** The Query Builder object, for chaining
184
+-   `key` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object))** The name of the field and the comparision operator, or an object
185
+-   `val` **\[([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** The value to compare if the value of key is a string
171 186
 
172
-## groupEnd
187
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
173 188
 
174
-Ends a logical grouping started with one of the groupStart methods
189
+## orHaving
175 190
 
176
-Returns **QueryBuilder** The Query Builder object, for chaining
191
+Add an 'or having' clause
177 192
 
178
-## groupStart
193
+**Parameters**
179 194
 
180
-Adds an open paren to the current query for logical grouping
195
+-   `key` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object))** The name of the field and the comparision operator, or an object
196
+-   `val` **\[([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** The value to compare if the value of key is a string
181 197
 
182
-Returns **QueryBuilder** The Query Builder object, for chaining
198
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
183 199
 
184
-## having
200
+## where
185 201
 
186
-Add a 'having' clause
202
+Set a 'where' clause
187 203
 
188 204
 **Parameters**
189 205
 
190
--   `key` **String or Object** The name of the field and the comparision operator, or an object
191
--   `val` **[String or Number]** The value to compare if the value of key is a string
206
+-   `key` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object))** The name of the field and the comparision operator, or an object
207
+-   `val` **\[([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** The value to compare if the value of key is a string
192 208
 
193
-Returns **QueryBuilder** The Query Builder object, for chaining
209
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
194 210
 
195
-## insert
211
+## orWhere
196 212
 
197
-Run the generated insert query
213
+Set a 'or where' clause
198 214
 
199 215
 **Parameters**
200 216
 
201
--   `table` **String** The table to insert into
202
--   `data` **[Object]** Data to insert, if not already added with the 'set' method
203
--   `callback` **[Function]** Callback for handling response from the database
217
+-   `key` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object))** The name of the field and the comparision operator, or an object
218
+-   `val` **\[([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** The value to compare if the value of key is a string
204 219
 
205
-Returns **void or Promise** If no callback is passed, a promise is returned
220
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
206 221
 
207
-## insertBatch
222
+## whereIsNull
208 223
 
209
-Insert multiple sets of rows at a time
224
+Select a field that is Null
210 225
 
211 226
 **Parameters**
212 227
 
213
--   `table` **String** The table to insert into
214
--   `data` **Array** The array of objects containing data rows to insert
215
--   `callback` **[Function]** Callback for handling database response
216
-
217
-**Examples**
228
+-   `field` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the field that has a NULL value
218 229
 
219
-```javascript
220
-query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}], callbackFunction);
221
-```
230
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
222 231
 
223
-```javascript
224
-query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}])
225
-.then(promiseCallback);
226
-```
227
-
228
-Returns **void or Promise** If no callback is passed, a promise is returned
229
-
230
-## join
232
+## whereIsNotNull
231 233
 
232
-Add a join clause to the query
234
+Specify that a field IS NOT NULL
233 235
 
234 236
 **Parameters**
235 237
 
236
--   `table` **String** The table you are joining
237
--   `cond` **String** The join condition.
238
--   `type` **[String]** The type of join, which defaults to inner (optional, default `'inner'`)
238
+-   `field` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name so the field that is not to be null
239 239
 
240
-Returns **QueryBuilder** The Query Builder object, for chaining
240
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
241 241
 
242
-## like
242
+## orWhereIsNull
243 243
 
244
-Add a 'like/ and like' clause to the query
244
+Field is null prefixed with 'OR'
245 245
 
246 246
 **Parameters**
247 247
 
248
--   `field` **String** The name of the field  to compare to
249
--   `val` **String** The value to compare to
250
--   `pos` **[String]** The placement of the wildcard character(s): before, after, or both (optional, default `both`)
248
+-   `field` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the field
251 249
 
252
-Returns **QueryBuilder** The Query Builder object, for chaining
250
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
253 251
 
254
-## limit
252
+## orWhereIsNotNull
255 253
 
256
-Put a limit on the query
254
+Field is not null prefixed with 'OR'
257 255
 
258 256
 **Parameters**
259 257
 
260
--   `limit` **Number** The maximum number of rows to fetch
261
--   `offset` **[Number]** The row number to start from
258
+-   `field` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the field
262 259
 
263
-Returns **QueryBuilder** The Query Builder object, for chaining
260
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
264 261
 
265
-## notLike
262
+## whereIn
266 263
 
267
-Add a 'not like/ and not like' clause to the query
264
+Set a 'where in' clause
268 265
 
269 266
 **Parameters**
270 267
 
271
--   `field` **String** The name of the field  to compare to
272
--   `val` **String** The value to compare to
273
--   `pos` **[String]** The placement of the wildcard character(s): before, after, or both (optional, default `both`)
268
+-   `key` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the field to search
269
+-   `values` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** the array of items to search in
274 270
 
275
-Returns **QueryBuilder** The Query Builder object, for chaining
271
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
276 272
 
277
-## orGroupStart
278
-
279
-Adds an open paren to the current query for logical grouping,
280
-prefixed with 'OR'
281
-
282
-Returns **QueryBuilder** The Query Builder object, for chaining
283
-
284
-## orHaving
273
+## orWhereIn
285 274
 
286
-Add an 'or having' clause
275
+Set a 'or where in' clause
287 276
 
288 277
 **Parameters**
289 278
 
290
--   `key` **String or Object** The name of the field and the comparision operator, or an object
291
--   `val` **[String or Number]** The value to compare if the value of key is a string
279
+-   `key` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the field to search
280
+-   `values` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** the array of items to search in
292 281
 
293
-Returns **QueryBuilder** The Query Builder object, for chaining
282
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
294 283
 
295
-## orLike
284
+## whereNotIn
296 285
 
297
-Add an 'or like' clause to the query
286
+Set a 'where not in' clause
298 287
 
299 288
 **Parameters**
300 289
 
301
--   `field` **String** The name of the field  to compare to
302
--   `val` **String** The value to compare to
303
--   `pos` **[String]** The placement of the wildcard character(s): before, after, or both (optional, default `both`)
290
+-   `key` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the field to search
291
+-   `values` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** the array of items to search in
304 292
 
305
-Returns **QueryBuilder** The Query Builder object, for chaining
293
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
306 294
 
307
-## orNotGroupStart
295
+## orWhereNotIn
308 296
 
309
-Adds an open paren to the current query for logical grouping,
310
-prefixed with 'OR NOT'
297
+Set a 'or where not in' clause
311 298
 
312
-Returns **QueryBuilder** The Query Builder object, for chaining
299
+**Parameters**
313 300
 
314
-## orNotLike
301
+-   `key` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the field to search
302
+-   `values` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** the array of items to search in
315 303
 
316
-Add an 'or not like' clause to the query
304
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
317 305
 
318
-**Parameters**
306
+## set
319 307
 
320
--   `field` **String** The name of the field  to compare to
321
--   `val` **String** The value to compare to
322
--   `pos` **[String]** The placement of the wildcard character(s): before, after, or both (optional, default `both`)
308
+Set values for insertion or updating
323 309
 
324
-Returns **QueryBuilder** The Query Builder object, for chaining
310
+**Parameters**
325 311
 
326
-## orWhere
312
+-   `key` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object))** The key or object to use
313
+-   `val` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The value if using a scalar key
327 314
 
328
-Set a 'or where' clause
315
+**Examples**
329 316
 
330
-**Parameters**
317
+```javascript
318
+query.set('foo', 'bar'); // Set a key, value pair
319
+```
331 320
 
332
--   `key` **String or Object** The name of the field and the comparision operator, or an object
333
--   `val` **[String or Number]** The value to compare if the value of key is a string
321
+```javascript
322
+query.set({foo:'bar'}); // Set with an object
323
+```
334 324
 
335
-Returns **QueryBuilder** The Query Builder object, for chaining
325
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
336 326
 
337
-## orWhereIn
327
+## join
338 328
 
339
-Set a 'or where in' clause
329
+Add a join clause to the query
340 330
 
341 331
 **Parameters**
342 332
 
343
--   `key` **String** the field to search
344
--   `values` **Array** the array of items to search in
333
+-   `table` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The table you are joining
334
+-   `cond` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The join condition.
335
+-   `type` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The type of join, which defaults to inner (optional, default `'inner'`)
345 336
 
346
-Returns **QueryBuilder** The Query Builder object, for chaining
337
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
347 338
 
348
-## orWhereIsNotNull
339
+## groupBy
349 340
 
350
-Field is not null prefixed with 'OR'
341
+Group the results by the selected field(s)
351 342
 
352 343
 **Parameters**
353 344
 
354
--   `field` **String** The name of the field
345
+-   `field` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array))** The name of the field to group by
355 346
 
356
-Returns **QueryBuilder** The Query Builder object, for chaining
347
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
357 348
 
358
-## orWhereIsNull
349
+## orderBy
359 350
 
360
-Field is null prefixed with 'OR'
351
+Order the results by the selected field(s)
361 352
 
362 353
 **Parameters**
363 354
 
364
--   `field` **String** The name of the field
355
+-   `field` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The field(s) to order by
356
+-   `type` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The order direction, ASC or DESC (optional, default `'ASC'`)
365 357
 
366
-Returns **QueryBuilder** The Query Builder object, for chaining
358
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
367 359
 
368
-## orWhereNotIn
360
+## limit
369 361
 
370
-Set a 'or where not in' clause
362
+Put a limit on the query
371 363
 
372 364
 **Parameters**
373 365
 
374
--   `key` **String** the field to search
375
--   `values` **Array** the array of items to search in
366
+-   `limit` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The maximum number of rows to fetch
367
+-   `offset` **\[[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** The row number to start from
376 368
 
377
-Returns **QueryBuilder** The Query Builder object, for chaining
369
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
378 370
 
379
-## orderBy
380
-
381
-Order the results by the selected field(s)
371
+## groupStart
382 372
 
383
-**Parameters**
373
+Adds an open paren to the current query for logical grouping
384 374
 
385
--   `field` **String** The field(s) to order by
386
--   `type` **[String]** The order direction, ASC or DESC (optional, default `'ASC'`)
375
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
387 376
 
388
-Returns **QueryBuilder** The Query Builder object, for chaining
377
+## orGroupStart
389 378
 
390
-## query
379
+Adds an open paren to the current query for logical grouping,
380
+prefixed with 'OR'
391 381
 
392
-Run an arbitrary sql query. Run as a prepared statement.
382
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
393 383
 
394
-**Parameters**
384
+## orNotGroupStart
395 385
 
396
--   `sql` **string** The sql to execute
397
--   `params` **[array]** The query parameters
398
--   `callback` **[function]** Optional callback
386
+Adds an open paren to the current query for logical grouping,
387
+prefixed with 'OR NOT'
399 388
 
400
-Returns **void or Promise** Returns a promise if no callback is supplied
389
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
401 390
 
402
-## resetQuery
391
+## groupEnd
403 392
 
404
-Reset the object state for a new query
393
+Ends a logical grouping started with one of the groupStart methods
405 394
 
406
-Returns **void** 
395
+Returns **[QueryBuilder](#querybuilder)** The Query Builder object, for chaining
407 396
 
408
-## select
397
+## get
409 398
 
410
-Specify rows to select in the query
399
+Get the results of the compiled query
411 400
 
412 401
 **Parameters**
413 402
 
414
--   `fields` **String or Array** The fields to select from the current table
403
+-   `table` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The table to select from
404
+-   `limit` **\[[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** A limit for the query
405
+-   `offset` **\[[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** An offset for the query
415 406
 
416 407
 **Examples**
417 408
 
418 409
 ```javascript
419
-query.select('foo, bar'); // Select multiple fields with a string
410
+query.get('table_name').then(promiseCallback); // Get all the rows in the table
420 411
 ```
421 412
 
422 413
 ```javascript
423
-query.select(['foo', 'bar']); // Select multiple fileds with an array
414
+query.get('table_name', 5); // Get 5 rows from the table
424 415
 ```
425 416
 
426
-Returns **QueryBuilder** The Query Builder object, for chaining
417
+```javascript
418
+query.get(); // Get the results of a query generated with other methods
419
+```
427 420
 
428
-## set
421
+Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Result](#result)>** Promise containing the result of the query
429 422
 
430
-Set values for insertion or updating
423
+## insert
431 424
 
432
-**Parameters**
425
+Run the generated insert query
433 426
 
434
--   `key` **String or Object** The key or object to use
435
--   `val` **[String]** The value if using a scalar key
427
+**Parameters**
436 428
 
437
-**Examples**
429
+-   `table` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The table to insert into
430
+-   `data` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Data to insert, if not already added with the 'set' method
438 431
 
439
-```javascript
440
-query.set('foo', 'bar'); // Set a key, value pair
441
-```
432
+Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Result](#result)>** Promise containing the result of the query
442 433
 
443
-```javascript
444
-query.set({foo:'bar'}); // Set with an object
445
-```
434
+## insertBatch
446 435
 
447
-Returns **QueryBuilder** The Query Builder object, for chaining
436
+Insert multiple sets of rows at a time
448 437
 
449
-## truncate
438
+**Parameters**
450 439
 
451
-Empties the selected database table
440
+-   `table` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The table to insert into
441
+-   `data` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** The array of objects containing data rows to insert
452 442
 
453
-**Parameters**
443
+**Examples**
454 444
 
455
--   `table` **string** the name of the table to truncate
456
--   `callback` **[function]** Optional callback
445
+```javascript
446
+query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}])
447
+.then(promiseCallback);
448
+```
457 449
 
458
-Returns **void or Promise** Returns a promise if no callback is supplied
450
+Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Result](#result)>** Promise containing the result of the query
459 451
 
460 452
 ## update
461 453
 
@@ -463,64 +455,65 @@ Run the generated update query
463 455
 
464 456
 **Parameters**
465 457
 
466
--   `table` **String** The table to insert into
467
--   `data` **[Object]** Data to insert, if not already added with the 'set' method
468
--   `callback` **[Function]** Callback for handling response from the database
458
+-   `table` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The table to insert into
459
+-   `data` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Data to insert, if not already added with the 'set' method
469 460
 
470
-Returns **void or Promise** If no callback is passed, a promise is returned
461
+Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Result](#result)>** Promise containing the result of the query
471 462
 
472
-## where
463
+## delete
473 464
 
474
-Set a 'where' clause
465
+Run the generated delete query
475 466
 
476 467
 **Parameters**
477 468
 
478
--   `key` **String or Object** The name of the field and the comparision operator, or an object
479
--   `val` **[String or Number]** The value to compare if the value of key is a string
469
+-   `table` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The table to insert into
470
+-   `where` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Where clause for delete statement
480 471
 
481
-Returns **QueryBuilder** The Query Builder object, for chaining
472
+Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Result](#result)>** Promise containing the result of the query
482 473
 
483
-## whereIn
474
+## getCompiledSelect
484 475
 
485
-Set a 'where in' clause
476
+Return generated select query SQL
486 477
 
487 478
 **Parameters**
488 479
 
489
--   `key` **String** the field to search
490
--   `values` **Array** the array of items to search in
480
+-   `table` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** the name of the table to retrieve from
481
+-   `reset` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Whether to reset the query builder so another query can be built (optional, default `true`)
491 482
 
492
-Returns **QueryBuilder** The Query Builder object, for chaining
483
+Returns **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The compiled sql statement
493 484
 
494
-## whereIsNotNull
485
+## getCompiledInsert
495 486
 
496
-Specify that a field IS NOT NULL
487
+Return generated insert query SQL
497 488
 
498 489
 **Parameters**
499 490
 
500
--   `field` **String** The name so the field that is not to be null
491
+-   `table` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the table to insert into
492
+-   `reset` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Whether to reset the query builder so another query can be built (optional, default `true`)
501 493
 
502
-Returns **QueryBuilder** The Query Builder object, for chaining
494
+Returns **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The compiled sql statement
503 495
 
504
-## whereIsNull
496
+## getCompiledUpdate
505 497
 
506
-Select a field that is Null
498
+Return generated update query SQL
507 499
 
508 500
 **Parameters**
509 501
 
510
--   `field` **String** The name of the field that has a NULL value
502
+-   `table` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the table to update
503
+-   `reset` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Whether to reset the query builder so another query can be built (optional, default `true`)
511 504
 
512
-Returns **QueryBuilder** The Query Builder object, for chaining
505
+Returns **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The compiled sql statement
513 506
 
514
-## whereNotIn
507
+## getCompiledDelete
515 508
 
516
-Set a 'where not in' clause
509
+Return generated delete query SQL
517 510
 
518 511
 **Parameters**
519 512
 
520
--   `key` **String** the field to search
521
--   `values` **Array** the array of items to search in
513
+-   `table` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the table to delete from
514
+-   `reset` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Whether to reset the query builder so another query can be built (optional, default `true`)
522 515
 
523
-Returns **QueryBuilder** The Query Builder object, for chaining
516
+Returns **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The compiled sql statement
524 517
 
525 518
 # Result
526 519
 
@@ -528,17 +521,17 @@ Query result object
528 521
 
529 522
 **Parameters**
530 523
 
531
--   `rows` **Array** the data rows of the result
532
--   `columns` **Array** the column names in the result
524
+-   `rows` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** the data rows of the result
525
+-   `columns` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** the column names in the result
533 526
 
534
-## columnCount
527
+## rowCount
535 528
 
536
-Get the number of columns returned by the query
529
+Get the number of rows returned by the query
537 530
 
538
-Returns **Number** the number of columns in the result
531
+Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the number of rows in the result
539 532
 
540
-## rowCount
533
+## columnCount
541 534
 
542
-Get the number of rows returned by the query
535
+Get the number of columns returned by the query
543 536
 
544
-Returns **Number** the number of rows in the result
537
+Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the number of columns in the result

+ 5
- 1
CHANGELOG.md View File

@@ -1,5 +1,9 @@
1 1
 # Changelog
2 2
 
3
+# 5.0.0
4
+* Re-added firebird as a database
5
+* Replaced all callback interfaces with promises
6
+
3 7
 ## 4.0.0
4 8
 * Changed connection setup to just use a config object - the appropriate adapter object is created by the library.
5 9
 * Removed mysql adapter, as mysql2 is very similar and does proper prepared statements
@@ -11,4 +15,4 @@
11 15
 * Added back tests for `node-firebird` adapter. Using this adapter with promises is not currently supported.
12 16
 
13 17
 ## 3.1.0
14
-* Added support for promises on query execution methods
18
+* Added support for promises on query execution methods

+ 6
- 13
README.md View File

@@ -9,6 +9,7 @@ A node query builder for various SQL databases, based on [CodeIgniter](http://ww
9 9
 
10 10
 ### Supported databases
11 11
 
12
+* Firebird (via `node-firebird`)
12 13
 * Mysql (via `mysql2`)
13 14
 * PostgreSQL (via `pg`)
14 15
 * Sqlite (via `dblite`)
@@ -38,19 +39,9 @@ const nodeQuery = require('ci-node-query')({
38 39
 // Get the query builder
39 40
 const query = nodeQuery.getQuery();
40 41
 
41
-query.select('foo')
42
-	.from('bar')
43
-	.where('x', 3)
44
-	.orWhere({y: 2})
45
-	.join('baz', 'baz.boo = bar.foo', 'left')
46
-	.orderBy('x', 'DESC')
47
-	.limit(2, 3)
48
-	.get(function(err, result) {
49
-		// Handle Results Here
50
-	});
51
-
52 42
 // As of version 3.1.0, you can also get promises
53
-var queryPromise = query.select('foo')
43
+// Version 5.0.0 removes all callback interfaces
44
+const queryPromise = query.select('foo')
54 45
 	.from('bar')
55 46
 	.where('x', 3)
56 47
 	.orWhere({y: 2})
@@ -93,5 +84,7 @@ As of version 2, `where` and `having` type methods parse the values passed to lo
93 84
 * Generated documentation is in the docs/ folder
94 85
 * The API is documented in [API.md](./API.md)
95 86
 * The `tests/adapters` folder contains examples of how to set up a connection for the appropriate database library
96
-* The documentation generated for the latest dev build is also [Available](https://github.timshomepage.net/node-query/docs/)
87
+* The documentation generated for the latest dev build is also [Available](https://github.timshomepage.net/node-query/docs/index.html)
88
+
89
+[![js-happiness-style](https://cdn.rawgit.com/JedWatson/happiness/master/badge.svg)](https://github.com/JedWatson/happiness)
97 90
 

+ 12
- 0
docs/assets/bass-addons.css View File

@@ -0,0 +1,12 @@
1
+.input {
2
+  font-family: inherit;
3
+  display: block;
4
+  width: 100%;
5
+  height: 2rem;
6
+  padding: .5rem;
7
+  margin-bottom: 1rem;
8
+  border: 1px solid #ccc;
9
+  font-size: .875rem;
10
+  border-radius: 3px;
11
+  box-sizing: border-box;
12
+}

+ 379
- 686
docs/assets/bass.css
File diff suppressed because it is too large
View File


BIN
docs/assets/fonts/EOT/SourceCodePro-Bold.eot View File


BIN
docs/assets/fonts/EOT/SourceCodePro-Regular.eot View File


+ 93
- 0
docs/assets/fonts/LICENSE.txt View File

@@ -0,0 +1,93 @@
1
+Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries.
2
+
3
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+
5
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
6
+
7
+
8
+-----------------------------------------------------------
9
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+-----------------------------------------------------------
11
+
12
+PREAMBLE
13
+The goals of the Open Font License (OFL) are to stimulate worldwide
14
+development of collaborative font projects, to support the font creation
15
+efforts of academic and linguistic communities, and to provide a free and
16
+open framework in which fonts may be shared and improved in partnership
17
+with others.
18
+
19
+The OFL allows the licensed fonts to be used, studied, modified and
20
+redistributed freely as long as they are not sold by themselves. The
21
+fonts, including any derivative works, can be bundled, embedded, 
22
+redistributed and/or sold with any software provided that any reserved
23
+names are not used by derivative works. The fonts and derivatives,
24
+however, cannot be released under any other type of license. The
25
+requirement for fonts to remain under this license does not apply
26
+to any document created using the fonts or their derivatives.
27
+
28
+DEFINITIONS
29
+"Font Software" refers to the set of files released by the Copyright
30
+Holder(s) under this license and clearly marked as such. This may
31
+include source files, build scripts and documentation.
32
+
33
+"Reserved Font Name" refers to any names specified as such after the
34
+copyright statement(s).
35
+
36
+"Original Version" refers to the collection of Font Software components as
37
+distributed by the Copyright Holder(s).
38
+
39
+"Modified Version" refers to any derivative made by adding to, deleting,
40
+or substituting -- in part or in whole -- any of the components of the
41
+Original Version, by changing formats or by porting the Font Software to a
42
+new environment.
43
+
44
+"Author" refers to any designer, engineer, programmer, technical
45
+writer or other person who contributed to the Font Software.
46
+
47
+PERMISSION & CONDITIONS
48
+Permission is hereby granted, free of charge, to any person obtaining
49
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+redistribute, and sell modified and unmodified copies of the Font
51
+Software, subject to the following conditions:
52
+
53
+1) Neither the Font Software nor any of its individual components,
54
+in Original or Modified Versions, may be sold by itself.
55
+
56
+2) Original or Modified Versions of the Font Software may be bundled,
57
+redistributed and/or sold with any software, provided that each copy
58
+contains the above copyright notice and this license. These can be
59
+included either as stand-alone text files, human-readable headers or
60
+in the appropriate machine-readable metadata fields within text or
61
+binary files as long as those fields can be easily viewed by the user.
62
+
63
+3) No Modified Version of the Font Software may use the Reserved Font
64
+Name(s) unless explicit written permission is granted by the corresponding
65
+Copyright Holder. This restriction only applies to the primary font name as
66
+presented to the users.
67
+
68
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+Software shall not be used to promote, endorse or advertise any
70
+Modified Version, except to acknowledge the contribution(s) of the
71
+Copyright Holder(s) and the Author(s) or with their explicit written
72
+permission.
73
+
74
+5) The Font Software, modified or unmodified, in part or in whole,
75
+must be distributed entirely under this license, and must not be
76
+distributed under any other license. The requirement for fonts to
77
+remain under this license does not apply to any document created
78
+using the Font Software.
79
+
80
+TERMINATION
81
+This license becomes null and void if any of the above conditions are
82
+not met.
83
+
84
+DISCLAIMER
85
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+OTHER DEALINGS IN THE FONT SOFTWARE.

BIN
docs/assets/fonts/OTF/SourceCodePro-Bold.otf View File


BIN
docs/assets/fonts/OTF/SourceCodePro-Regular.otf View File


BIN
docs/assets/fonts/TTF/SourceCodePro-Bold.ttf View File


BIN
docs/assets/fonts/TTF/SourceCodePro-Regular.ttf View File


BIN
docs/assets/fonts/WOFF/OTF/SourceCodePro-Bold.otf.woff View File


BIN
docs/assets/fonts/WOFF/OTF/SourceCodePro-Regular.otf.woff View File


BIN
docs/assets/fonts/WOFF/TTF/SourceCodePro-Bold.ttf.woff View File


BIN
docs/assets/fonts/WOFF/TTF/SourceCodePro-Regular.ttf.woff View File


BIN
docs/assets/fonts/WOFF2/OTF/SourceCodePro-Bold.otf.woff2 View File


BIN
docs/assets/fonts/WOFF2/OTF/SourceCodePro-Regular.otf.woff2 View File


BIN
docs/assets/fonts/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2 View File


BIN
docs/assets/fonts/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2 View File


+ 23
- 0
docs/assets/fonts/source-code-pro.css View File

@@ -0,0 +1,23 @@
1
+@font-face{
2
+    font-family: 'Source Code Pro';
3
+    font-weight: 400;
4
+    font-style: normal;
5
+    font-stretch: normal;
6
+    src: url('EOT/SourceCodePro-Regular.eot') format('embedded-opentype'),
7
+         url('WOFF2/TTF/SourceCodePro-Regular.ttf.woff2') format('woff2'),
8
+         url('WOFF/OTF/SourceCodePro-Regular.otf.woff') format('woff'),
9
+         url('OTF/SourceCodePro-Regular.otf') format('opentype'),
10
+         url('TTF/SourceCodePro-Regular.ttf') format('truetype');
11
+}
12
+
13
+@font-face{
14
+    font-family: 'Source Code Pro';
15
+    font-weight: 700;
16
+    font-style: normal;
17
+    font-stretch: normal;
18
+    src: url('EOT/SourceCodePro-Bold.eot') format('embedded-opentype'),
19
+         url('WOFF2/TTF/SourceCodePro-Bold.ttf.woff2') format('woff2'),
20
+         url('WOFF/OTF/SourceCodePro-Bold.otf.woff') format('woff'),
21
+         url('OTF/SourceCodePro-Bold.otf') format('opentype'),
22
+         url('TTF/SourceCodePro-Bold.ttf') format('truetype');
23
+}

+ 89
- 21
docs/assets/site.js View File

@@ -2,39 +2,107 @@
2 2
 
3 3
 // add anchor links to headers
4 4
 anchors.options.placement = 'left';
5
-anchors.add().remove('.no-anchor');
5
+anchors.add('h3');
6 6
 
7 7
 // Filter UI
8
-var tocElements = document.getElementById('toc').getElementsByTagName('a');
9
-document.getElementById('filter-input').addEventListener('keyup', function(e) {
8
+var tocElements = document.getElementById('toc')
9
+  .getElementsByTagName('li');
10 10
 
11
-  var i, element;
11
+document.getElementById('filter-input')
12
+  .addEventListener('keyup', function (e) {
13
+
14
+    var i, element, children;
15
+
16
+    // enter key
17
+    if (e.keyCode === 13) {
18
+      // go to the first displayed item in the toc
19
+      for (i = 0; i < tocElements.length; i++) {
20
+        element = tocElements[i];
21
+        if (!element.classList.contains('display-none')) {
22
+          location.replace(element.firstChild.href);
23
+          return e.preventDefault();
24
+        }
25
+      }
26
+    }
27
+
28
+    var match = function () {
29
+      return true;
30
+    };
31
+
32
+    var value = this.value.toLowerCase();
33
+
34
+    if (!value.match(/^\s*$/)) {
35
+      match = function (element) {
36
+        return element.firstChild.innerHTML.toLowerCase().indexOf(value) !== -1;
37
+      };
38
+    }
12 39
 
13
-  // enter key
14
-  if (e.keyCode === 13) {
15
-    // go to the first displayed item in the toc
16 40
     for (i = 0; i < tocElements.length; i++) {
17 41
       element = tocElements[i];
18
-      if (!element.classList.contains('hide')) {
19
-        location.replace(element.href);
20
-        return e.preventDefault();
42
+      children = Array.from(element.getElementsByTagName('li'));
43
+      if (match(element) || children.some(match)) {
44
+        element.classList.remove('display-none');
45
+      } else {
46
+        element.classList.add('display-none');
21 47
       }
22 48
     }
49
+  });
50
+
51
+var toggles = document.getElementsByClassName('toggle-step-sibling');
52
+for (var i = 0; i < toggles.length; i++) {
53
+  toggles[i].addEventListener('click', toggleStepSibling);
54
+}
55
+
56
+function toggleStepSibling() {
57
+  var stepSibling = this.parentNode.parentNode.parentNode.getElementsByClassName('toggle-target')[0];
58
+  var klass = 'display-none';
59
+  if (stepSibling.classList.contains(klass)) {
60
+    stepSibling.classList.remove(klass);
61
+    stepSibling.innerHTML = '▾';
62
+  } else {
63
+    stepSibling.classList.add(klass);
64
+    stepSibling.innerHTML = '▸';
23 65
   }
66
+}
24 67
 
25
-  var match = function() { return true; },
26
-    value = this.value.toLowerCase();
68
+var items = document.getElementsByClassName('toggle-sibling');
69
+for (var j = 0; j < items.length; j++) {
70
+  items[j].addEventListener('click', toggleSibling);
71
+}
27 72
 
28
-  if (!value.match(/^\s*$/)) {
29
-    match = function(text) { return text.toLowerCase().indexOf(value) !== -1; };
73
+function toggleSibling() {
74
+  var stepSibling = this.parentNode.getElementsByClassName('toggle-target')[0];
75
+  var icon = this.getElementsByClassName('icon')[0];
76
+  var klass = 'display-none';
77
+  if (stepSibling.classList.contains(klass)) {
78
+    stepSibling.classList.remove(klass);
79
+    icon.innerHTML = '▾';
80
+  } else {
81
+    stepSibling.classList.add(klass);
82
+    icon.innerHTML = '▸';
30 83
   }
84
+}
31 85
 
32
-  for (i = 0; i < tocElements.length; i++) {
33
-    element = tocElements[i];
34
-    if (match(element.innerHTML)) {
35
-      element.classList.remove('hide');
36
-    } else {
37
-      element.classList.add('hide');
38
-    }
86
+function showHashTarget(targetId) {
87
+  var hashTarget = document.getElementById(targetId);
88
+  // new target is hidden
89
+  if (hashTarget && hashTarget.offsetHeight === 0 &&
90
+    hashTarget.parentNode.parentNode.classList.contains('display-none')) {
91
+    hashTarget.parentNode.parentNode.classList.remove('display-none');
39 92
   }
93
+}
94
+
95
+window.addEventListener('hashchange', function() {
96
+  showHashTarget(location.hash.substring(1));
40 97
 });
98
+
99
+showHashTarget(location.hash.substring(1));
100
+
101
+var toclinks = document.getElementsByClassName('pre-open');
102
+for (var k = 0; k < toclinks.length; k++) {
103
+  toclinks[k].addEventListener('mousedown', preOpen, false);
104
+}
105
+
106
+function preOpen() {
107
+  showHashTarget(this.hash.substring(1));
108
+}

+ 88
- 47
docs/assets/style.css View File

@@ -1,66 +1,53 @@
1
-.documentation a {
2
-  color: #1184CE;
3
-}
4
-
5
-.documentation .suppress-p-margin p {
6
-  margin:0;
1
+.documentation {
2
+  font-family: Helvetica, sans-serif;
3
+  color: #666;
4
+  line-height: 1.5;
5
+  background: #f5f5f5;
7 6
 }
8 7
 
9
-.force-inline, .force-inline p {
10
-  display: inline;
11
-  color: #222;
8
+.black {
9
+  color: #666;
12 10
 }
13 11
 
14
-.container-small {
15
-  max-width: 58rem;
16
-  margin-left: auto;
17
-  margin-right: auto;
12
+.bg-white {
13
+  background-color: #fff;
18 14
 }
19 15
 
20
-.max-height-100 {
21
-  max-height: 100%;
16
+h4 {
17
+  margin: 20px 0 10px 0;
22 18
 }
23 19
 
24
-.fade {
25
-  opacity:0.50;
20
+.documentation h3 {
21
+  color: #000;
26 22
 }
27 23
 
28
-.button-indent {
29
-  padding: .25rem 1.5rem;
30
-  font-size: 90%;
24
+.border-bottom {
25
+  border-color: #ddd;
31 26
 }
32 27
 
33
-.section-indent {
34
-  border-left: 2px solid #eee;
28
+a {
29
+  color: #1184CE;
30
+  text-decoration: none;
35 31
 }
36 32
 
37
-.bg-cloudy {
38
-  background: #fafafa;
33
+.documentation a[href]:hover {
34
+  text-decoration: underline;
39 35
 }
40 36
 
41
-.force-inline * {
42
-  display:inline;
37
+a:hover {
38
+  cursor: pointer;
43 39
 }
44 40
 
45
-section:target h3 {
46
-  font-weight:700;
41
+.py1-ul li {
42
+  padding: 5px 0;
47 43
 }
48 44
 
49
-.documentation,
50
-.documentation h1,
51
-.documentation h2,
52
-.documentation h3,
53
-.documentation h4,
54
-.documentation h5,
55
-.documentation h6 {
56
-    font-family: 'Source Sans Pro', Helvetica, sans-serif;
45
+.max-height-100 {
46
+  max-height: 100%;
57 47
 }
58 48
 
59
-.documentation pre,
60
-.documentation code,
61
-.documentation samp {
62
-  font-family: 'Source Code Pro', monospace;
63
-  font-size: 90%;
49
+section:target h3 {
50
+  font-weight:700;
64 51
 }
65 52
 
66 53
 .documentation td,
@@ -75,12 +62,9 @@ h4:hover .anchorjs-link {
75 62
   opacity: 1;
76 63
 }
77 64
 
78
-.collapsible .collapser {
79
-  display:none;
80
-}
81
-
82
-.collapsible:target .collapser {
83
-  display: block;
65
+.fix-3 {
66
+  width: 25%;
67
+  max-width: 244px;
84 68
 }
85 69
 
86 70
 .fix-3 {
@@ -93,3 +77,60 @@ h4:hover .anchorjs-link {
93 77
     margin-left: 25%;
94 78
   }
95 79
 }
80
+
81
+.pre, pre, code, .code {
82
+  font-family: Source Code Pro,Menlo,Consolas,Liberation Mono,monospace;
83
+  font-size: 14px;
84
+}
85
+
86
+.fill-light {
87
+  background: #F9F9F9;
88
+}
89
+
90
+.width2 {
91
+  width: 1rem;
92
+}
93
+
94
+.input {
95
+  font-family: inherit;
96
+  display: block;
97
+  width: 100%;
98
+  height: 2rem;
99
+  padding: .5rem;
100
+  margin-bottom: 1rem;
101
+  border: 1px solid #ccc;
102
+  font-size: .875rem;
103
+  border-radius: 3px;
104
+  box-sizing: border-box;
105
+}
106
+
107
+table {
108
+  border-collapse: collapse;
109
+}
110
+
111
+.prose table th,
112
+.prose table td {
113
+  text-align: left;
114
+  padding:8px;
115
+  border:1px solid #ddd;
116
+}
117
+
118
+.prose table th:nth-child(1) { border-right: none; }
119
+.prose table th:nth-child(2) { border-left: none; }
120
+
121
+.prose table {
122
+  border:1px solid #ddd;
123
+}
124
+
125
+.prose-big {
126
+  font-size: 18px;
127
+  line-height: 30px;
128
+}
129
+
130
+.quiet {
131
+  opacity: 0.7;
132
+}
133
+
134
+.minishadow {
135
+  box-shadow: 2px 2px 10px #f3f3f3;
136
+}

+ 3660
- 2132
docs/index.html
File diff suppressed because it is too large
View File


+ 0
- 87
gulpfile.js View File

@@ -1,87 +0,0 @@
1
-'use strict';
2
-
3
-const documentation = require('gulp-documentation'),
4
-	eslint = require('gulp-eslint'),
5
-	gulp = require('gulp'),
6
-	istanbul = require('gulp-istanbul'),
7
-	jscs = require('gulp-jscs'),
8
-	mocha = require('gulp-mocha'),
9
-	pipe = require('gulp-pipe'),
10
-	sloc = require('gulp-sloc');
11
-
12
-const SRC_FILES = ['lib/**/*.js'];
13
-const TEST_FILES = [
14
-	'test/*_test.js',
15
-	'test/adapters/*_test.js'
16
-];
17
-
18
-const MOCHA_OPTIONS = {
19
-	ui: 'tdd',
20
-	bail: true,
21
-	reporter: 'dot',
22
-	timeout: 10000,
23
-};
24
-
25
-gulp.task('lint', () => {
26
-	pipe(gulp.src(SRC_FILES), [
27
-		eslint(),
28
-		eslint.format(),
29
-		eslint.failAfterError()
30
-	]);
31
-	pipe(gulp.src(SRC_FILES), [
32
-		jscs(),
33
-		jscs.reporter()
34
-	]);
35
-});
36
-
37
-gulp.task('lint-tests', ['lint'], () => {
38
-	pipe(gulp.src(['test/**/*.js']), [
39
-		eslint(),
40
-		eslint.format(),
41
-		eslint.failAfterError()
42
-	]);
43
-	pipe(gulp.src(['test/**/*.js']), [
44
-		jscs(),
45
-		jscs.reporter()
46
-	]);
47
-});
48
-
49
-gulp.task('sloc', () => gulp.src(SRC_FILES).pipe(sloc()));
50
-gulp.task('test-sloc', () => gulp.src(TEST_FILES).pipe(sloc()));
51
-
52
-gulp.task('docs', () => {
53
-	gulp.src(['lib/*.js'])
54
-		.pipe(documentation({format: 'html'}))
55
-		.pipe(gulp.dest('docs'));
56
-	gulp.src(['lib/*.js'])
57
-		.pipe(documentation({format: 'md'}))
58
-		.pipe(gulp.dest('.'));
59
-});
60
-
61
-gulp.task('mocha', ['lint-tests', 'sloc'], () => {
62
-	return gulp.src(TEST_FILES)
63
-		.pipe(mocha(MOCHA_OPTIONS))
64
-		.once('error', () => {
65
-			process.exit(1);
66
-		})
67
-		.once('end', () => {
68
-			process.exit();
69
-	});
70
-});
71
-
72
-gulp.task('test', ['test-sloc', 'lint-tests'], function(cb) {
73
-	return pipe(gulp.src(SRC_FILES), [
74
-		istanbul(),
75
-		istanbul.hookRequire()
76
-	]).on('finish', () => {
77
-		pipe(gulp.src(TEST_FILES), [
78
-			mocha(MOCHA_OPTIONS),
79
-			istanbul.writeReports({
80
-				dir: './coverage',
81
-				reporters: ['clover', 'lcov', 'lcovonly', 'html', 'text'],
82
-			}),
83
-		]);
84
-	});
85
-});
86
-
87
-gulp.task('default', ['lint', 'sloc', 'docs', 'test']);

+ 9
- 11
lib/Adapter.js View File

@@ -1,20 +1,19 @@
1
-
2 1
 'use strict';
3 2
 
4 3
 /**
5 4
  * Class that wraps database connection libraries
6 5
  *
7 6
  * @private
8
- * @param  {Object} instance - The connection object
7
+ * @param  {Promise} instance - The connection object
9 8
  */
10 9
 class Adapter {
11 10
 	/**
12 11
 	 * Invoke an adapter
13 12
 	 *
14 13
 	 * @constructor
15
-	 * @param  {Object} instance - The connection object
14
+	 * @param  {Promise} instance - Promise holding connection object
16 15
 	 */
17
-	constructor(instance) {
16
+	constructor (instance) {
18 17
 		this.instance = instance;
19 18
 	}
20 19
 
@@ -23,10 +22,9 @@ class Adapter {
23 22
 	 *
24 23
 	 * @param {String} sql - The sql with placeholders
25 24
 	 * @param {Array} params - The values to insert into the query
26
-	 * @param {Function} [callback] - Callback to run when a response is recieved
27
-	 * @return {void|Promise} - returns a promise if no callback is passed
25
+	 * @return {Promise} - returns a promise if no callback is passed
28 26
 	 */
29
-	execute(/*sql, params, callback*/) {
27
+	execute (sql, params) {
30 28
 		throw new Error('Correct adapter not defined for query execution');
31 29
 	}
32 30
 
@@ -36,7 +34,7 @@ class Adapter {
36 34
 	 * @param {*} originalResult - the original result object from the driver
37 35
 	 * @return {Result} - the new result object
38 36
 	 */
39
-	transformResult(originalResult) {
37
+	transformResult (originalResult) {
40 38
 		throw new Error('Result transformer method not defined for current adapter');
41 39
 	}
42 40
 
@@ -44,9 +42,9 @@ class Adapter {
44 42
 	 * Close the current database connection
45 43
 	 * @return {void}
46 44
 	 */
47
-	close() {
48
-		this.instance.end();
45
+	close () {
46
+		this.instance.then(conn => conn.end());
49 47
 	}
50 48
 }
51 49
 
52
-module.exports = Adapter;
50
+module.exports = Adapter;

+ 31
- 34
lib/Driver.js View File

@@ -7,7 +7,7 @@ const helpers = require('./helpers');
7 7
  *
8 8
  * @private
9 9
  */
10
-let Driver = {
10
+const Driver = {
11 11
 	identifierStartChar: '"',
12 12
 	identifierEndChar: '"',
13 13
 	tablePrefix: null,
@@ -20,9 +20,9 @@ let Driver = {
20 20
 	 * @return {String} - The quoted sql fragment
21 21
 	 * @private
22 22
 	 */
23
-	_quote(str) {
24
-		return (helpers.isString(str)
25
-			&& ! (str.startsWith(Driver.identifierStartChar) || str.endsWith(Driver.identifierEndChar))
23
+	_quote (str) {
24
+		return (helpers.isString(str) &&
25
+			!(str.startsWith(Driver.identifierStartChar) || str.endsWith(Driver.identifierEndChar))
26 26
 		)
27 27
 			? `${Driver.identifierStartChar}${str}${Driver.identifierEndChar}`
28 28
 			: str;
@@ -30,17 +30,16 @@ let Driver = {
30 30
 
31 31
 	/**
32 32
 	 * Set the limit clause
33
-
33
+	 * @private
34 34
 	 * @param {String} sql - SQL statement to modify
35 35
 	 * @param {Number} limit - Maximum number of rows to fetch
36 36
 	 * @param {Number} [offset] - Number of rows to skip
37 37
 	 * @return {String} - Modified SQL statement
38 38
 	 */
39
-	limit(sql, limit, offset) {
40
-		sql +=  ` LIMIT ${limit}`;
39
+	limit (sql, limit, offset) {
40
+		sql += ` LIMIT ${limit}`;
41 41
 
42
-		if (helpers.isNumber(offset))
43
-		{
42
+		if (helpers.isNumber(offset)) {
44 43
 			sql += ` OFFSET ${offset}`;
45 44
 		}
46 45
 
@@ -50,10 +49,11 @@ let Driver = {
50 49
 	/**
51 50
 	 * Quote database table name, and set prefix
52 51
 	 *
52
+	 * @private
53 53
 	 * @param {String} table - Table name to quote
54 54
 	 * @return {String} - Quoted table name
55 55
 	 */
56
-	quoteTable(table) {
56
+	quoteTable (table) {
57 57
 		// Quote after prefix
58 58
 		return Driver.quoteIdentifiers(table);
59 59
 	},
@@ -61,25 +61,24 @@ let Driver = {
61 61
 	/**
62 62
 	 * Use the driver's escape character to quote identifiers
63 63
 	 *
64
+	 * @private
64 65
 	 * @param {String|Array} str - String or array of strings to quote identifiers
65 66
 	 * @return {String|Array} - Quoted identifier(s)
66 67
 	 */
67
-	quoteIdentifiers(str) {
68
+	quoteIdentifiers (str) {
68 69
 		let hiers, raw;
69 70
 		let pattern = new RegExp(
70
-			`${Driver.identifierStartChar}(`
71
-				+ '([a-zA-Z0-9_]+)' + '(\((.*?)\))'
72
-				+ `)${Driver.identifierEndChar}`, 'ig');
71
+			`${Driver.identifierStartChar}(` +
72
+				'([a-zA-Z0-9_]+)' + '(((.*?)))' +
73
+				`)${Driver.identifierEndChar}`, 'ig');
73 74
 
74 75
 		// Recurse for arrays of identifiiers
75
-		if (Array.isArray(str))
76
-		{
76
+		if (Array.isArray(str)) {
77 77
 			return str.map(Driver.quoteIdentifiers);
78 78
 		}
79 79
 
80 80
 		// Handle commas
81
-		if (str.includes(','))
82
-		{
81
+		if (str.includes(',')) {
83 82
 			let parts = str.split(',').map(helpers.stringTrim);
84 83
 			str = parts.map(Driver.quoteIdentifiers).join(',');
85 84
 		}
@@ -89,8 +88,7 @@ let Driver = {
89 88
 		raw = hiers.join('.');
90 89
 
91 90
 		// Fix functions
92
-		if (raw.includes('(') && raw.includes(')'))
93
-		{
91
+		if (raw.includes('(') && raw.includes(')')) {
94 92
 			let funcs = pattern.exec(raw);
95 93
 
96 94
 			// Unquote the function
@@ -107,10 +105,11 @@ let Driver = {
107 105
 	/**
108 106
 	 * Generate SQL to truncate the passed table
109 107
 	 *
108
+	 * @private
110 109
 	 * @param {String} table - Table to truncate
111 110
 	 * @return {String} - Truncation SQL
112 111
 	 */
113
-	truncate(table) {
112
+	truncate (table) {
114 113
 		let sql = (Driver.hasTruncate)
115 114
 			? 'TRUNCATE '
116 115
 			: 'DELETE FROM ';
@@ -123,17 +122,15 @@ let Driver = {
123 122
 	/**
124 123
 	 * Generate SQL to insert a group of rows
125 124
 	 *
125
+	 * @private
126 126
 	 * @param {String} table - The table to insert to
127 127
 	 * @param {Array} [data] - The array of object containing data to insert
128 128
 	 * @return {String} - Query and data to insert
129 129
 	 */
130
-	insertBatch(table, data) {
131
-		let vals = [],
132
-			fields = Object.keys(data[0]),
133
-			sql = '',
134
-			params = [],
135
-			paramString = '',
136
-			paramList = [];
130
+	insertBatch (table, data) {
131
+		const vals = [];
132
+		const fields = Object.keys(data[0]);
133
+		let sql = '';
137 134
 
138 135
 		// Get the data values to insert, so they can
139 136
 		// be parameterized
@@ -150,17 +147,17 @@ let Driver = {
150 147
 		sql += `INSERT INTO ${table} (${Driver.quoteIdentifiers(fields).join(',')}) VALUES `;
151 148
 
152 149
 		// Create placeholder groups
153
-		params = Array(fields.length).fill('?');
154
-		paramString = `(${params.join(',')})`;
155
-		paramList = Array(data.length).fill(paramString);
150
+		let params = Array(fields.length).fill('?');
151
+		let paramString = `(${params.join(',')})`;
152
+		let paramList = Array(data.length).fill(paramString);
156 153
 
157 154
 		sql += paramList.join(',');
158 155
 
159 156
 		return {
160 157
 			sql: sql,
161
-			values: vals,
158
+			values: vals
162 159
 		};
163
-	},
160
+	}
164 161
 };
165 162
 
166
-module.exports = Driver;
163
+module.exports = Driver;

+ 10
- 10
lib/NodeQuery.js View File

@@ -1,6 +1,5 @@
1 1
 'use strict';
2 2
 
3
-const helpers = require('./helpers');
4 3
 const QueryBuilder = require('./QueryBuilder');
5 4
 
6 5
 // Map config driver name to code class name
@@ -15,6 +14,8 @@ const dbDriverMap = new Map([
15 14
 	['pg', 'Pg'],
16 15
 	['sqlite3', 'Sqlite'],
17 16
 	['sqlite', 'Sqlite'],
17
+	['sqlserver', 'MSSQLServer'],
18
+	['mssql', 'MSSQLServer']
18 19
 ]);
19 20
 
20 21
 /**
@@ -23,7 +24,6 @@ const dbDriverMap = new Map([
23 24
  * @param {object} config - connection parameters
24 25
  */
25 26
 class NodeQuery {
26
-
27 27
 	/**
28 28
 	 * Constructor
29 29
 	 *
@@ -42,20 +42,20 @@ class NodeQuery {
42 42
 	 * 	connection: ':memory:'
43 43
 	 * });
44 44
 	 */
45
-	constructor(config) {
45
+	constructor (config) {
46 46
 		this.instance = null;
47 47
 
48
-		if (config != null) {
48
+		if (config !== undefined) {
49 49
 			let drivername = dbDriverMap.get(config.driver);
50 50
 
51
-			if (! drivername) {
51
+			if (!drivername) {
52 52
 				throw new Error(`Selected driver (${config.driver}) does not exist!`);
53 53
 			}
54 54
 
55
-			let driver = require(`./drivers/${drivername}`);
56
-			let $adapter = require(`./adapters/${drivername}`);
55
+			const driver = require(`./drivers/${drivername}`);
56
+			const Adapter = require(`./adapters/${drivername}`);
57 57
 
58
-			let adapter = new $adapter(config.connection);
58
+			let adapter = Adapter(config);
59 59
 			this.instance = new QueryBuilder(driver, adapter);
60 60
 		}
61 61
 	}
@@ -65,7 +65,7 @@ class NodeQuery {
65 65
 	 *
66 66
 	 * @return {QueryBuilder} - The Query Builder object
67 67
 	 */
68
-	getQuery() {
68
+	getQuery () {
69 69
 		if (this.instance == null) {
70 70
 			throw new Error('No Query Builder instance to return');
71 71
 		}
@@ -74,4 +74,4 @@ class NodeQuery {
74 74
 	}
75 75
 }
76 76
 
77
-module.exports = (config => new NodeQuery(config));
77
+module.exports = config => new NodeQuery(config);

+ 79
- 402
lib/QueryBuilder.js View File

@@ -1,309 +1,16 @@
1 1
 'use strict';
2 2
 
3
-const getArgs = require('getargs');
4 3
 const helpers = require('./helpers');
5
-const State = require('./State');
6
-const QueryParser = require('./QueryParser');
7
-
8
-class QueryBuilderBase {
9
-	/**
10
-	 * @private
11
-	 * @constructor
12
-	 * @param {Driver} Driver - The syntax driver for the database
13
-	 * @param {Adapter} Adapter - The database module adapter for running queries
14
-	 */
15
-	constructor(Driver, Adapter) {
16
-		this.driver = Driver;
17
-		this.adapter = Adapter;
18
-		this.parser = new QueryParser(this.driver);
19
-		this.state = new State();
20
-	}
21
-
22
-	/**
23
-	 * Complete the sql building based on the type provided
24
-	 *
25
-	 * @private
26
-	 * @param {String} type - Type of SQL query
27
-	 * @param {String} table - The table to run the query on
28
-	 * @return {String} - The compiled sql
29
-	 */
30
-	_compile(type, table) {
31
-		// Put together the basic query
32
-		let sql = this._compileType(type, table);
33
-
34
-		// Set each subClause
35
-		['queryMap', 'groupString', 'orderString', 'havingMap'].forEach(clause => {
36
-			let param = this.state[clause];
37
-
38
-			if (! helpers.isScalar(param)) {
39
-				Object.keys(param).forEach(part => {
40
-					sql += param[part].conjunction + param[part].string;
41
-				});
42
-			} else {
43
-				sql += param;
44
-			}
45
-		});
46
-
47
-		// Append the limit, if it exists
48
-		if (helpers.isNumber(this.state.limit)) {
49
-			sql = this.driver.limit(sql, this.state.limit, this.state.offset);
50
-		}
51
-
52
-		return sql;
53
-	}
54
-
55
-	_compileType(type, table) {
56
-		let sql = '';
57
-
58
-		switch (type) {
59
-			case 'insert':
60
-				let params = Array(this.state.setArrayKeys.length).fill('?');
61
-
62
-				sql = `INSERT INTO ${table} (`;
63
-				sql += this.state.setArrayKeys.join(',');
64
-				sql += `) VALUES (${params.join(',')})`;
65
-			break;
66
-
67
-			case 'update':
68
-				sql = `UPDATE ${table} SET ${this.state.setString}`;
69
-			break;
70
-
71
-			case 'delete':
72
-				sql = `DELETE FROM ${table}`;
73
-			break;
74
-
75
-			default:
76
-				sql = `SELECT * FROM ${this.state.fromString}`;
77
-
78
-				// Set the select string
79
-				if (this.state.selectString.length > 0) {
80
-					// Replace the star with the selected fields
81
-					sql = sql.replace('*', this.state.selectString);
82
-				}
83
-
84
-			break;
85
-		}
86
-
87
-		return sql;
88
-	}
89
-
90
-	_like(field, val, pos, like, conj) {
91
-		field = this.driver.quoteIdentifiers(field);
92
-
93
-		like = `${field} ${like} ?`;
94
-
95
-		if (pos === 'before') {
96
-			val = `%${val}`;
97
-		} else if (pos === 'after') {
98
-			val = `${val}%`;
99
-		} else {
100
-			val = `%${val}%`;
101
-		}
102
-
103
-		conj = (this.state.queryMap.length < 1) ? ' WHERE ' : ` ${conj} `;
104
-		this._appendMap(conj, like, 'like');
105
-
106
-		this.state.whereValues.push(val);
107
-	}
108
-
109
-	/**
110
-	 * Append a clause to the query map
111
-	 *
112
-	 * @private
113
-	 * @param {String} conjunction - linking keyword for the clause
114
-	 * @param {String} string - pre-compiled sql fragment
115
-	 * @param {String} type - type of sql clause
116
-	 * @return {void}
117
-	 */
118
-	_appendMap(conjunction, string, type) {
119
-		this.state.queryMap.push({
120
-			type: type,
121
-			conjunction: conjunction,
122
-			string: string,
123
-		});
124
-	}
125
-
126
-	/**
127
-	 * Handle key/value pairs in an object the same way as individual arguments,
128
-	 * when appending to state
129
-	 *
130
-	 * @private
131
-	 * @return {Array} - modified state array
132
-	 */
133
-	_mixedSet(/* $letName, $valType, $key, [$val] */) {
134
-		const argPattern = '$letName:string, $valType:string, $key:object|string|number, [$val]';
135
-		let args = getArgs(argPattern, arguments);
136
-
137
-		let obj = {};
138
-
139
-		if (helpers.isScalar(args.$key) && !helpers.isUndefined(args.$val)) {
140
-			// Convert key/val pair to a simple object
141
-			obj[args.$key] = args.$val;
142
-		} else if (helpers.isScalar(args.$key) && helpers.isUndefined(args.$val)) {
143
-			// If just a string for the key, and no value, create a simple object with duplicate key/val
144
-			obj[args.$key] = args.$key;
145
-		} else {
146
-			obj = args.$key;
147
-		}
148
-
149
-		Object.keys(obj).forEach(k => {
150
-			// If a single value for the return
151
-			if (['key', 'value'].indexOf(args.$valType) !== -1) {
152
-				let pushVal = (args.$valType === 'key') ? k : obj[k];
153
-				this.state[args.$letName].push(pushVal);
154
-			} else {
155
-				this.state[args.$letName][k] = obj[k];
156
-			}
157
-		});
158
-
159
-		return this.state[args.$letName];
160
-	}
161
-
162
-	_whereMixedSet(/*key, val*/) {
163
-		let args = getArgs('key:string|object, [val]', arguments);
164
-
165
-		this.state.whereMap = [];
166
-		this.state.rawWhereValues = [];
167
-
168
-		this._mixedSet('whereMap', 'both', args.key, args.val);
169
-		this._mixedSet('rawWhereValues', 'value', args.key, args.val);
170
-	}
171
-
172
-	_fixConjunction(conj) {
173
-		let lastItem = this.state.queryMap[this.state.queryMap.length - 1];
174
-		let conjunctionList = helpers.arrayPluck(this.state.queryMap, 'conjunction');
175
-
176
-		if (this.state.queryMap.length === 0 || (! helpers.regexInArray(conjunctionList, /^ ?WHERE/i))) {
177
-			conj = ' WHERE ';
178
-		} else if (lastItem.type === 'groupStart') {
179
-			conj = '';
180
-		} else {
181
-			conj = ` ${conj} `;
182
-		}
183
-
184
-		return conj;
185
-	}
186
-
187
-	_where(key, val, defaultConj) {
188
-		// Normalize key and value and insert into this.state.whereMap
189
-		this._whereMixedSet(key, val);
190
-
191
-		// Parse the where condition to account for operators,
192
-		// functions, identifiers, and literal values
193
-		this.state = this.parser.parseWhere(this.driver, this.state);
194
-
195
-		this.state.whereMap.forEach(clause => {
196
-			let conj = this._fixConjunction(defaultConj);
197
-			this._appendMap(conj, clause, 'where');
198
-		});
199
-
200
-		this.state.whereMap = {};
201
-	}
202
-
203
-	_whereNull(field, stmt, conj) {
204
-		field = this.driver.quoteIdentifiers(field);
205
-		let item = `${field} ${stmt}`;
206
-
207
-		this._appendMap(this._fixConjunction(conj), item, 'whereNull');
208
-	}
209
-
210
-	_having(/*key, val, conj*/) {
211
-		let args = getArgs('key:string|object, [val]:string|number, [conj]:string', arguments);
212
-		args.conj = args.conj || 'AND';
213
-		args.val = args.val || null;
214
-
215
-		// Normalize key/val and put in state.whereMap
216
-		this._whereMixedSet(args.key, args.val);
217
-
218
-		// Parse the having condition to account for operators,
219
-		// functions, identifiers, and literal values
220
-		this.state = this.parser.parseWhere(this.driver, this.state);
221
-
222
-		this.state.whereMap.forEach(clause => {
223
-			// Put in the having map
224
-			this.state.havingMap.push({
225
-				conjunction: (this.state.havingMap.length > 0) ? ` ${args.conj} ` : ' HAVING ',
226
-				string: clause,
227
-			});
228
-		});
229
-
230
-		// Clear the where Map
231
-		this.state.whereMap = {};
232
-
233
-	}
234
-
235
-	_whereIn(/*key, val, inClause, conj*/) {
236
-		let args = getArgs('key:string, val:array, inClause:string, conj:string', arguments);
237
-
238
-		args.key = this.driver.quoteIdentifiers(args.key);
239
-		let params = Array(args.val.length);
240
-		params.fill('?');
241
-
242
-		args.val.forEach(value => {
243
-			this.state.whereValues.push(value);
244
-		});
245
-
246
-		args.conj = (this.state.queryMap.length > 0) ? ` ${args.conj} ` : ' WHERE ';
247
-		let str = `${args.key} ${args.inClause} (${params.join(',')}) `;
248
-
249
-		this._appendMap(args.conj, str, 'whereIn');
250
-	}
251
-
252
-	_run(type, table, callback, sql, vals) {
253
-
254
-		if (! sql) {
255
-			sql = this._compile(type, table);
256
-		}
257
-
258
-		if (! vals) {
259
-			vals = this.state.values.concat(this.state.whereValues);
260
-		}
261
-
262
-		// Reset the state so another query can be built
263
-		this._resetState();
264
-
265
-		// Pass the sql and values to the adapter to run on the database
266
-		if (callback) {
267
-			return this.query(sql, vals, callback);
268
-		} else {
269
-			return this.query(sql, vals);
270
-		}
271
-	}
272
-
273
-	_getCompile(type, table, reset) {
274
-		reset = reset || false;
275
-
276
-		let sql = this._compile(type, table);
277
-
278
-		if (reset) {
279
-			this._resetState();
280
-		}
281
-
282
-		return sql;
283
-	}
284
-
285
-	_resetState() {
286
-		this.state = new State();
287
-	}
288
-}
4
+const QueryBuilderBase = require('./QueryBuilderBase');
289 5
 
290 6
 /**
291 7
  * Main object that builds SQL queries.
292 8
  *
293 9
  * @param {Driver} Driver - The syntax driver for the database
294 10
  * @param {Adapter} Adapter - The database module adapter for running queries
11
+ * @extends QueryBuilderBase
295 12
  */
296 13
 class QueryBuilder extends QueryBuilderBase {
297
-	/**
298
-	 * @private
299
-	 * @constructor
300
-	 * @param {Driver} Driver - The syntax driver for the database
301
-	 * @param {Adapter} Adapter - The database module adapter for running queries
302
-	 */
303
-	constructor(Driver, Adapter) {
304
-		super(Driver, Adapter);
305
-	}
306
-
307 14
 	// ----------------------------------------------------------------------------
308 15
 	// ! Miscellaneous Methods
309 16
 	// ----------------------------------------------------------------------------
@@ -312,12 +19,11 @@ class QueryBuilder extends QueryBuilderBase {
312 19
 	 * Run an arbitrary sql query. Run as a prepared statement.
313 20
 	 *
314 21
 	 * @param {string} sql - The sql to execute
315
-	 * @param {array} [params] - The query parameters
316
-	 * @param {function} [callback] - Optional callback
317
-	 * @return {void|Promise} - Returns a promise if no callback is supplied
22
+	 * @param {Array} [params] - The query parameters
23
+	 * @return {Promise} - Promise with result of query
318 24
 	 */
319
-	query(/*sql:string, [params]:array, [callback]:function*/) {
320
-		return this.adapter.execute.apply(this.adapter, arguments);
25
+	query (sql, params) {
26
+		return this.adapter.execute(sql, params);
321 27
 	}
322 28
 
323 29
 	/**
@@ -325,7 +31,7 @@ class QueryBuilder extends QueryBuilderBase {
325 31
 	 *
326 32
 	 * @return {void}
327 33
 	 */
328
-	resetQuery() {
34
+	resetQuery () {
329 35
 		this._resetState();
330 36
 	}
331 37
 
@@ -335,7 +41,7 @@ class QueryBuilder extends QueryBuilderBase {
335 41
 	 * @private
336 42
 	 * @return {Object} - The State object
337 43
 	 */
338
-	getState() {
44
+	getState () {
339 45
 		return this.state;
340 46
 	}
341 47
 
@@ -343,15 +49,10 @@ class QueryBuilder extends QueryBuilderBase {
343 49
 	 * Empties the selected database table
344 50
 	 *
345 51
 	 * @param {string} table - the name of the table to truncate
346
-	 * @param {function} [callback] - Optional callback
347 52
 	 * @return {void|Promise} - Returns a promise if no callback is supplied
348 53
 	 */
349
-	truncate(/*table:string, [callback]:function*/) {
350
-		getArgs('table:string, [callback]:function', arguments);
351
-		let args = [].slice.apply(arguments);
352
-		let sql = this.driver.truncate(args.shift());
353
-		args.unshift(sql);
354
-		return this.query.apply(this, args);
54
+	truncate (table) {
55
+		return this.query(this.driver.truncate(table));
355 56
 	}
356 57
 
357 58
 	/**
@@ -359,7 +60,7 @@ class QueryBuilder extends QueryBuilderBase {
359 60
 	 *
360 61
 	 * @return {void}
361 62
 	 */
362
-	end() {
63
+	end () {
363 64
 		this.adapter.close();
364 65
 	}
365 66
 
@@ -375,8 +76,7 @@ class QueryBuilder extends QueryBuilderBase {
375 76
 	 * @example query.select(['foo', 'bar']); // Select multiple fileds with an array
376 77
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
377 78
 	 */
378
-	select(fields) {
379
-
79
+	select (fields) {
380 80
 		// Split/trim fields by comma
381 81
 		fields = (Array.isArray(fields))
382 82
 			? fields
@@ -384,7 +84,7 @@ class QueryBuilder extends QueryBuilderBase {
384 84
 
385 85
 		// Split on 'As'
386 86
 		fields.forEach((field, index) => {
387
-			if (field.match(/as/i)) {
87
+			if (/as/i.test(field)) {
388 88
 				fields[index] = field.split(/ as /i).map(helpers.stringTrim);
389 89
 			}
390 90
 		});
@@ -411,7 +111,7 @@ class QueryBuilder extends QueryBuilderBase {
411 111
 	 * @example query.from('tableName t'); // Select the table with an alias
412 112
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
413 113
 	 */
414
-	from(tableName) {
114
+	from (tableName) {
415 115
 		// Split identifiers on spaces
416 116
 		let identArray = tableName.trim().split(' ').map(helpers.stringTrim);
417 117
 
@@ -433,7 +133,7 @@ class QueryBuilder extends QueryBuilderBase {
433 133
 	 * @param {String} [pos=both] - The placement of the wildcard character(s): before, after, or both
434 134
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
435 135
 	 */
436
-	like(field, val, pos) {
136
+	like (field, val, pos) {
437 137
 		this._like(field, val, pos, ' LIKE ', 'AND');
438 138
 		return this;
439 139
 	}
@@ -446,7 +146,7 @@ class QueryBuilder extends QueryBuilderBase {
446 146
 	 * @param {String} [pos=both] - The placement of the wildcard character(s): before, after, or both
447 147
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
448 148
 	 */
449
-	notLike(field, val, pos) {
149
+	notLike (field, val, pos) {
450 150
 		this._like(field, val, pos, ' NOT LIKE ', 'AND');
451 151
 		return this;
452 152
 	}
@@ -459,7 +159,7 @@ class QueryBuilder extends QueryBuilderBase {
459 159
 	 * @param {String} [pos=both] - The placement of the wildcard character(s): before, after, or both
460 160
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
461 161
 	 */
462
-	orLike(field, val, pos) {
162
+	orLike (field, val, pos) {
463 163
 		this._like(field, val, pos, ' LIKE ', 'OR');
464 164
 		return this;
465 165
 	}
@@ -472,7 +172,7 @@ class QueryBuilder extends QueryBuilderBase {
472 172
 	 * @param {String} [pos=both] - The placement of the wildcard character(s): before, after, or both
473 173
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
474 174
 	 */
475
-	orNotLike(field, val, pos) {
175
+	orNotLike (field, val, pos) {
476 176
 		this._like(field, val, pos, ' NOT LIKE ', 'OR');
477 177
 		return this;
478 178
 	}
@@ -484,10 +184,8 @@ class QueryBuilder extends QueryBuilderBase {
484 184
 	 * @param {String|Number} [val] - The value to compare if the value of key is a string
485 185
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
486 186
 	 */
487
-	having(/*key, [val]*/) {
488
-		let args = getArgs('key:string|object, [val]:string|number', arguments);
489
-
490
-		this._having(args.key, args.val, 'AND');
187
+	having (key, val = null) {
188
+		this._having(key, val, 'AND');
491 189
 		return this;
492 190
 	}
493 191
 
@@ -498,10 +196,8 @@ class QueryBuilder extends QueryBuilderBase {
498 196
 	 * @param {String|Number} [val] - The value to compare if the value of key is a string
499 197
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
500 198
 	 */
501
-	orHaving(/*key, [val]*/) {
502
-		let args = getArgs('key:string|object, [val]:string|number', arguments);
503
-
504
-		this._having(args.key, args.val, 'OR');
199
+	orHaving (key, val = null) {
200
+		this._having(key, val, 'OR');
505 201
 		return this;
506 202
 	}
507 203
 
@@ -512,7 +208,7 @@ class QueryBuilder extends QueryBuilderBase {
512 208
 	 * @param {String|Number} [val] - The value to compare if the value of key is a string
513 209
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
514 210
 	 */
515
-	where(key, val) {
211
+	where (key, val) {
516 212
 		this._where(key, val, 'AND');
517 213
 		return this;
518 214
 	}
@@ -524,7 +220,7 @@ class QueryBuilder extends QueryBuilderBase {
524 220
 	 * @param {String|Number} [val] - The value to compare if the value of key is a string
525 221
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
526 222
 	 */
527
-	orWhere(key, val) {
223
+	orWhere (key, val) {
528 224
 		this._where(key, val, 'OR');
529 225
 		return this;
530 226
 	}
@@ -535,7 +231,7 @@ class QueryBuilder extends QueryBuilderBase {
535 231
 	 * @param {String} field - The name of the field that has a NULL value
536 232
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
537 233
 	 */
538
-	whereIsNull(field) {
234
+	whereIsNull (field) {
539 235
 		this._whereNull(field, 'IS NULL', 'AND');
540 236
 		return this;
541 237
 	}
@@ -546,7 +242,7 @@ class QueryBuilder extends QueryBuilderBase {
546 242
 	 * @param {String} field - The name so the field that is not to be null
547 243
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
548 244
 	 */
549
-	whereIsNotNull(field) {
245
+	whereIsNotNull (field) {
550 246
 		this._whereNull(field, 'IS NOT NULL', 'AND');
551 247
 		return this;
552 248
 	}
@@ -557,7 +253,7 @@ class QueryBuilder extends QueryBuilderBase {
557 253
 	 * @param {String} field - The name of the field
558 254
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
559 255
 	 */
560
-	orWhereIsNull(field) {
256
+	orWhereIsNull (field) {
561 257
 		this._whereNull(field, 'IS NULL', 'OR');
562 258
 		return this;
563 259
 	}
@@ -568,7 +264,7 @@ class QueryBuilder extends QueryBuilderBase {
568 264
 	 * @param {String} field - The name of the field
569 265
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
570 266
 	 */
571
-	orWhereIsNotNull(field) {
267
+	orWhereIsNotNull (field) {
572 268
 		this._whereNull(field, 'IS NOT NULL', 'OR');
573 269
 		return this;
574 270
 	}
@@ -580,7 +276,7 @@ class QueryBuilder extends QueryBuilderBase {
580 276
 	 * @param {Array} values - the array of items to search in
581 277
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
582 278
 	 */
583
-	whereIn(key, values) {
279
+	whereIn (key, values) {
584 280
 		this._whereIn(key, values, 'IN', 'AND');
585 281
 		return this;
586 282
 	}
@@ -592,7 +288,7 @@ class QueryBuilder extends QueryBuilderBase {
592 288
 	 * @param {Array} values - the array of items to search in
593 289
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
594 290
 	 */
595
-	orWhereIn(key, values) {
291
+	orWhereIn (key, values) {
596 292
 		this._whereIn(key, values, 'IN', 'OR');
597 293
 		return this;
598 294
 	}
@@ -604,7 +300,7 @@ class QueryBuilder extends QueryBuilderBase {
604 300
 	 * @param {Array} values - the array of items to search in
605 301
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
606 302
 	 */
607
-	whereNotIn(key, values) {
303
+	whereNotIn (key, values) {
608 304
 		this._whereIn(key, values, 'NOT IN', 'AND');
609 305
 		return this;
610 306
 	}
@@ -616,7 +312,7 @@ class QueryBuilder extends QueryBuilderBase {
616 312
 	 * @param {Array} values - the array of items to search in
617 313
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
618 314
 	 */
619
-	orWhereNotIn(key, values) {
315
+	orWhereNotIn (key, values) {
620 316
 		this._whereIn(key, values, 'NOT IN', 'OR');
621 317
 		return this;
622 318
 	}
@@ -630,12 +326,10 @@ class QueryBuilder extends QueryBuilderBase {
630 326
 	 * @example query.set({foo:'bar'}); // Set with an object
631 327
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
632 328
 	 */
633
-	set(/* $key, [$val] */) {
634
-		let args = getArgs('$key, [$val]', arguments);
635
-
329
+	set (key, val) {
636 330
 		// Set the appropriate state variables
637
-		this._mixedSet('setArrayKeys', 'key', args.$key, args.$val);
638
-		this._mixedSet('values', 'value', args.$key, args.$val);
331
+		this._mixedSet('setArrayKeys', 'key', key, val);
332
+		this._mixedSet('values', 'value', key, val);
639 333
 
640 334
 		// Use the keys of the array to make the insert/update string
641 335
 		// and escape the field names
@@ -656,7 +350,7 @@ class QueryBuilder extends QueryBuilderBase {
656 350
 	 * @param {String} [type='inner'] - The type of join, which defaults to inner
657 351
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
658 352
 	 */
659
-	join(table, cond, type) {
353
+	join (table, cond, type) {
660 354
 		type = type || 'inner';
661 355
 
662 356
 		// Prefix/quote table name
@@ -681,8 +375,8 @@ class QueryBuilder extends QueryBuilderBase {
681 375
 	 * @param {String|Array} field - The name of the field to group by
682 376
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
683 377
 	 */
684
-	groupBy(field) {
685
-		if (! helpers.isScalar(field)) {
378
+	groupBy (field) {
379
+		if (!helpers.isScalar(field)) {
686 380
 			let newGroupArray = field.map(this.driver.quoteIdentifiers);
687 381
 			this.state.groupArray = this.state.groupArray.concat(newGroupArray);
688 382
 		} else {
@@ -701,7 +395,7 @@ class QueryBuilder extends QueryBuilderBase {
701 395
 	 * @param {String} [type='ASC'] - The order direction, ASC or DESC
702 396
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
703 397
 	 */
704
-	orderBy(field, type) {
398
+	orderBy (field, type) {
705 399
 		type = type || 'ASC';
706 400
 
707 401
 		// Set the fields for later manipulation
@@ -729,7 +423,7 @@ class QueryBuilder extends QueryBuilderBase {
729 423
 	 * @param {Number} [offset] - The row number to start from
730 424
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
731 425
 	 */
732
-	limit(limit, offset) {
426
+	limit (limit, offset) {
733 427
 		this.state.limit = limit;
734 428
 		this.state.offset = offset || null;
735 429
 
@@ -741,7 +435,7 @@ class QueryBuilder extends QueryBuilderBase {
741 435
 	 *
742 436
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
743 437
 	 */
744
-	groupStart() {
438
+	groupStart () {
745 439
 		let conj = (this.state.queryMap.length < 1) ? ' WHERE ' : ' AND ';
746 440
 		this._appendMap(conj, '(', 'groupStart');
747 441
 
@@ -754,7 +448,7 @@ class QueryBuilder extends QueryBuilderBase {
754 448
 	 *
755 449
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
756 450
 	 */
757
-	orGroupStart() {
451
+	orGroupStart () {
758 452
 		this._appendMap('', ' OR (', 'groupStart');
759 453
 
760 454
 		return this;
@@ -766,7 +460,7 @@ class QueryBuilder extends QueryBuilderBase {
766 460
 	 *
767 461
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
768 462
 	 */
769
-	orNotGroupStart() {
463
+	orNotGroupStart () {
770 464
 		this._appendMap('', ' OR NOT (', 'groupStart');
771 465
 
772 466
 		return this;
@@ -777,7 +471,7 @@ class QueryBuilder extends QueryBuilderBase {
777 471
 	 *
778 472
 	 * @return {QueryBuilder} - The Query Builder object, for chaining
779 473
 	 */
780
-	groupEnd() {
474
+	groupEnd () {
781 475
 		this._appendMap('', ')', 'groupEnd');
782 476
 
783 477
 		return this;
@@ -793,26 +487,22 @@ class QueryBuilder extends QueryBuilderBase {
793 487
 	 * @param {String} [table] - The table to select from
794 488
 	 * @param {Number} [limit] - A limit for the query
795 489
 	 * @param {Number} [offset] - An offset for the query
796
-	 * @param {Function} [callback] - A callback for receiving the result
797 490
 	 * @example query.get('table_name').then(promiseCallback); // Get all the rows in the table
798
-	 * @example query.get('table_name', 5, callback); // Get 5 rows from the table
799
-	 * @example query.get(callback); // Get the results of a query generated with other methods
491
+	 * @example query.get('table_name', 5); // Get 5 rows from the table
492
+	 * @example query.get(); // Get the results of a query generated with other methods
800 493
 	 * @return {void|Promise} - If no callback is passed, a promise is returned
801 494
 	 */
802
-	get(/* [table], [limit], [offset], [callback] */) {
803
-		const argPattern = '[table]:string, [limit]:number, [offset]:number, [callback]:function';
804
-		let args = getArgs(argPattern, arguments);
805
-
806
-		if (args.table) {
807
-			this.from(args.table);
495
+	get (table, limit, offset) {
496
+		if (table) {
497
+			this.from(table);
808 498
 		}
809 499
 
810
-		if (args.limit) {
811
-			this.limit(args.limit, args.offset);
500
+		if (limit) {
501
+			this.limit(limit, offset);
812 502
 		}
813 503
 
814 504
 		// Run the query
815
-		return this._run('get', args.table, args.callback);
505
+		return this._run('get', table);
816 506
 	}
817 507
 
818 508
 	/**
@@ -820,18 +510,15 @@ class QueryBuilder extends QueryBuilderBase {
820 510
 	 *
821 511
 	 * @param {String} table - The table to insert into
822 512
 	 * @param {Object} [data] - Data to insert, if not already added with the 'set' method
823
-	 * @param {Function} [callback] - Callback for handling response from the database
824
-	 * @return {void|Promise} - If no callback is passed, a promise is returned
513
+	 * @return {Promise} - If no callback is passed, a promise is returned
825 514
 	 */
826
-	insert(/* table, data, callback */) {
827
-		let args = getArgs('table:string, [data]:object, [callback]:function', arguments);
828
-
829
-		if (args.data) {
830
-			this.set(args.data);
515
+	insert (table, data) {
516
+		if (data) {
517
+			this.set(data);
831 518
 		}
832 519
 
833 520
 		// Run the query
834
-		return this._run('insert', this.driver.quoteTable(args.table), args.callback);
521
+		return this._run('insert', this.driver.quoteTable(table));
835 522
 	}
836 523
 
837 524
 	/**
@@ -839,18 +526,15 @@ class QueryBuilder extends QueryBuilderBase {
839 526
 	 *
840 527
 	 * @param {String} table - The table to insert into
841 528
 	 * @param {Array} data - The array of objects containing data rows to insert
842
-	 * @param {Function} [callback] - Callback for handling database response
843
-	 * @example query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}], callbackFunction);
844 529
 	 * @example query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}])
845 530
 	 *.then(promiseCallback);
846
-	 * @return {void|Promise} - If no callback is passed, a promise is returned
531
+	 * @return {Promise} - If no callback is passed, a promise is returned
847 532
 	 */
848
-	insertBatch(/* table, data, callback */) {
849
-		let args = getArgs('table:string, data:array, [callback]:function', arguments);
850
-		let batch = this.driver.insertBatch(args.table, args.data);
533
+	insertBatch (table, data) {
534
+		let batch = this.driver.insertBatch(table, data);
851 535
 
852 536
 		// Run the query
853
-		return this._run('', '', args.callback, batch.sql, batch.values);
537
+		return this.query(batch.sql, batch.values);
854 538
 	}
855 539
 
856 540
 	/**
@@ -858,18 +542,15 @@ class QueryBuilder extends QueryBuilderBase {
858 542
 	 *
859 543
 	 * @param {String} table - The table to insert into
860 544
 	 * @param {Object} [data] - Data to insert, if not already added with the 'set' method
861
-	 * @param {Function} [callback] - Callback for handling response from the database
862
-	 * @return {void|Promise} - If no callback is passed, a promise is returned
545
+	 * @return {Promise} - If no callback is passed, a promise is returned
863 546
 	 */
864
-	update(/*table, data, callback*/) {
865
-		let args = getArgs('table:string, [data]:object, [callback]:function', arguments);
866
-
867
-		if (args.data) {
868
-			this.set(args.data);
547
+	update (table, data) {
548
+		if (data) {
549
+			this.set(data);
869 550
 		}
870 551
 
871 552
 		// Run the query
872
-		return this._run('update', this.driver.quoteTable(args.table), args.callback);
553
+		return this._run('update', this.driver.quoteTable(table));
873 554
 	}
874 555
 
875 556
 	/**
@@ -877,18 +558,15 @@ class QueryBuilder extends QueryBuilderBase {
877 558
 	 *