From ea15044d132afe2663bc5e7f32d414ed62b0d059 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Tue, 26 Jan 2016 20:23:52 -0500 Subject: [PATCH] Update some documentation --- API.md | 479 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 22 +- docs/index.html | 479 ++++++++++++++++++++++++++++++++++++++++++-- gulpfile.js | 5 +- lib/QueryBuilder.js | 37 ++-- 5 files changed, 991 insertions(+), 31 deletions(-) create mode 100644 API.md diff --git a/API.md b/API.md new file mode 100644 index 0000000..7cfc697 --- /dev/null +++ b/API.md @@ -0,0 +1,479 @@ +# NodeQuery + +Class for connection management + +## getQuery + +Return an existing query builder instance + +Returns **QueryBuilder** The Query Builder object + +## init + +Create a query builder object + +**Parameters** + +- `driverType` **String** The name of the database type, eg. mysql or pg +- `connObject` **Object** A connection object from the database library you are connecting with +- `connLib` **[String]** The name of the db connection library you are using, eg. mysql or mysql2. Optional if the same as driverType + +Returns **QueryBuilder** The Query Builder object + +# QueryBuilder + +Main object that builds SQL queries. + +**Parameters** + +- `Driver` **Driver** The syntax driver for the database +- `Adapter` **Adapter** The database module adapter for running queries + +## delete + +Run the generated delete query + +**Parameters** + +- `table` **String** The table to insert into +- `where` **[Object]** Where clause for delete statement +- `callback` **[Function]** Callback for handling response from the database + +Returns **void or Promise** If no callback is passed, a promise is returned + +## end + +Closes the database connection for the current adapter + +Returns **void** + +## from + +Specify the database table to select from + +**Parameters** + +- `tableName` **String** The table to use for the current query + +**Examples** + +```javascript +query.from('tableName'); +``` + +```javascript +query.from('tableName t'); // Select the table with an alias +``` + +Returns **QueryBuilder** The Query Builder object, for chaining + +## get + +Get the results of the compiled query + +**Parameters** + +- `table` **[String]** The table to select from +- `limit` **[Number]** A limit for the query +- `offset` **[Number]** An offset for the query +- `callback` **[Function]** A callback for receiving the result + +**Examples** + +```javascript +query.get('table_name').then(promiseCallback); // Get all the rows in the table +``` + +```javascript +query.get('table_name', 5, callback); // Get 5 rows from the table +``` + +```javascript +query.get(callback); // Get the results of a query generated with other methods +``` + +Returns **void or Promise** If no callback is passed, a promise is returned + +## getCompiledDelete + +Return generated delete query SQL + +**Parameters** + +- `table` **String** the name of the table to delete from +- `reset` **[Boolean]** Whether to reset the query builder so another query can be built (optional, default `true`) + +Returns **String** The compiled sql statement + +## getCompiledInsert + +Return generated insert query SQL + +**Parameters** + +- `table` **String** the name of the table to insert into +- `reset` **[Boolean]** Whether to reset the query builder so another query can be built (optional, default `true`) + +Returns **String** The compiled sql statement + +## getCompiledSelect + +Return generated select query SQL + +**Parameters** + +- `table` **[String]** the name of the table to retrieve from +- `reset` **[Boolean]** Whether to reset the query builder so another query can be built (optional, default `true`) + +Returns **String** The compiled sql statement + +## getCompiledUpdate + +Return generated update query SQL + +**Parameters** + +- `table` **String** the name of the table to update +- `reset` **[Boolean]** Whether to reset the query builder so another query can be built (optional, default `true`) + +Returns **String** The compiled sql statement + +## groupBy + +Group the results by the selected field(s) + +**Parameters** + +- `field` **String or Array** The name of the field to group by + +Returns **QueryBuilder** The Query Builder object, for chaining + +## groupEnd + +Ends a logical grouping started with one of the groupStart methods + +Returns **QueryBuilder** The Query Builder object, for chaining + +## groupStart + +Adds an open paren to the current query for logical grouping + +Returns **QueryBuilder** The Query Builder object, for chaining + +## having + +Add a 'having' clause + +**Parameters** + +- `key` **String or Object** The name of the field and the comparision operator, or an object +- `val` **[String or Number]** The value to compare if the value of key is a string + +Returns **QueryBuilder** The Query Builder object, for chaining + +## insert + +Run the generated insert query + +**Parameters** + +- `table` **String** The table to insert into +- `data` **[Object]** Data to insert, if not already added with the 'set' method +- `callback` **[Function]** Callback for handling response from the database + +Returns **void or Promise** If no callback is passed, a promise is returned + +## insertBatch + +Insert multiple sets of rows at a time + +**Parameters** + +- `table` **String** The table to insert into +- `data` **Array** The array of objects containing data rows to insert +- `callback` **[Function]** Callback for handling database response + +**Examples** + +```javascript +query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}], callbackFunction); +``` + +```javascript +query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}]) +.then(promiseCallback); +``` + +Returns **void or Promise** If no callback is passed, a promise is returned + +## join + +Add a join clause to the query + +**Parameters** + +- `table` **String** The table you are joining +- `cond` **String** The join condition. +- `type` **[String]** The type of join, which defaults to inner (optional, default `'inner'`) + +Returns **QueryBuilder** The Query Builder object, for chaining + +## like + +Add a 'like/ and like' clause to the query + +**Parameters** + +- `field` **String** The name of the field to compare to +- `val` **String** The value to compare to +- `pos` **[String]** The placement of the wildcard character(s): before, after, or both (optional, default `both`) + +Returns **QueryBuilder** The Query Builder object, for chaining + +## limit + +Put a limit on the query + +**Parameters** + +- `limit` **Number** The maximum number of rows to fetch +- `offset` **[Number]** The row number to start from + +Returns **QueryBuilder** The Query Builder object, for chaining + +## notLike + +Add a 'not like/ and not like' clause to the query + +**Parameters** + +- `field` **String** The name of the field to compare to +- `val` **String** The value to compare to +- `pos` **[String]** The placement of the wildcard character(s): before, after, or both (optional, default `both`) + +Returns **QueryBuilder** The Query Builder object, for chaining + +## orGroupStart + +Adds an open paren to the current query for logical grouping, +prefixed with 'OR' + +Returns **QueryBuilder** The Query Builder object, for chaining + +## orHaving + +Add an 'or having' clause + +**Parameters** + +- `key` **String or Object** The name of the field and the comparision operator, or an object +- `val` **[String or Number]** The value to compare if the value of key is a string + +Returns **QueryBuilder** The Query Builder object, for chaining + +## orLike + +Add an 'or like' clause to the query + +**Parameters** + +- `field` **String** The name of the field to compare to +- `val` **String** The value to compare to +- `pos` **[String]** The placement of the wildcard character(s): before, after, or both (optional, default `both`) + +Returns **QueryBuilder** The Query Builder object, for chaining + +## orNotGroupStart + +Adds an open paren to the current query for logical grouping, +prefixed with 'OR NOT' + +Returns **QueryBuilder** The Query Builder object, for chaining + +## orNotLike + +Add an 'or not like' clause to the query + +**Parameters** + +- `field` **String** The name of the field to compare to +- `val` **String** The value to compare to +- `pos` **[String]** The placement of the wildcard character(s): before, after, or both (optional, default `both`) + +Returns **QueryBuilder** The Query Builder object, for chaining + +## orWhere + +Set a 'or where' clause + +**Parameters** + +- `key` **String or Object** The name of the field and the comparision operator, or an object +- `val` **[String or Number]** The value to compare if the value of key is a string + +Returns **QueryBuilder** The Query Builder object, for chaining + +## orWhereIn + +Set a 'or where in' clause + +**Parameters** + +- `key` **String** the field to search +- `values` **Array** the array of items to search in + +Returns **QueryBuilder** The Query Builder object, for chaining + +## orWhereIsNotNull + +Field is not null prefixed with 'OR' + +**Parameters** + +- `field` **String** The name of the field + +Returns **QueryBuilder** The Query Builder object, for chaining + +## orWhereIsNull + +Field is null prefixed with 'OR' + +**Parameters** + +- `field` **String** The name of the field + +Returns **QueryBuilder** The Query Builder object, for chaining + +## orWhereNotIn + +Set a 'or where not in' clause + +**Parameters** + +- `key` **String** the field to search +- `values` **Array** the array of items to search in + +Returns **QueryBuilder** The Query Builder object, for chaining + +## orderBy + +Order the results by the selected field(s) + +**Parameters** + +- `field` **String** The field(s) to order by +- `type` **[String]** The order direction, ASC or DESC (optional, default `'ASC'`) + +Returns **QueryBuilder** The Query Builder object, for chaining + +## resetQuery + +Reset the object state for a new query + +Returns **void** + +## select + +Specify rows to select in the query + +**Parameters** + +- `fields` **String or Array** The fields to select from the current table + +**Examples** + +```javascript +query.select('foo, bar'); // Select multiple fields with a string +``` + +```javascript +query.select(['foo', 'bar']); // Select multiple fileds with an array +``` + +Returns **QueryBuilder** The Query Builder object, for chaining + +## set + +Set values for insertion or updating + +**Parameters** + +- `key` **String or Object** The key or object to use +- `val` **[String]** The value if using a scalar key + +**Examples** + +```javascript +query.set('foo', 'bar'); // Set a key, value pair +``` + +```javascript +query.set({foo:'bar'}); // Set with an object +``` + +Returns **QueryBuilder** The Query Builder object, for chaining + +## update + +Run the generated update query + +**Parameters** + +- `table` **String** The table to insert into +- `data` **[Object]** Data to insert, if not already added with the 'set' method +- `callback` **[Function]** Callback for handling response from the database + +Returns **void or Promise** If no callback is passed, a promise is returned + +## where + +Set a 'where' clause + +**Parameters** + +- `key` **String or Object** The name of the field and the comparision operator, or an object +- `val` **[String or Number]** The value to compare if the value of key is a string + +Returns **QueryBuilder** The Query Builder object, for chaining + +## whereIn + +Set a 'where in' clause + +**Parameters** + +- `key` **String** the field to search +- `values` **Array** the array of items to search in + +Returns **QueryBuilder** The Query Builder object, for chaining + +## whereIsNotNull + +Specify that a field IS NOT NULL + +**Parameters** + +- `field` **String** The name so the field that is not to be null + +Returns **QueryBuilder** The Query Builder object, for chaining + +## whereIsNull + +Select a field that is Null + +**Parameters** + +- `field` **String** The name of the field that has a NULL value + +Returns **QueryBuilder** The Query Builder object, for chaining + +## whereNotIn + +Set a 'where not in' clause + +**Parameters** + +- `key` **String** the field to search +- `values` **Array** the array of items to search in + +Returns **QueryBuilder** The Query Builder object, for chaining diff --git a/README.md b/README.md index bbf36a9..8293e54 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ #CI-Node-query -A node query builder for various SQL databases, based on CodeIgniter's query builder. +A node query builder for various SQL databases, based on [CodeIgniter](http://www.codeigniter.com/user_guide/database/query_builder.html)'s query builder. [![Build Status](https://jenkins.timshomepage.net/buildStatus/icon?job=node-query)](https://jenkins.timshomepage.net/job/node-query/) [![Build Status](https://travis-ci.org/timw4mail/node-query.svg?branch=master)](https://travis-ci.org/timw4mail/node-query) @@ -13,12 +13,13 @@ A node query builder for various SQL databases, based on CodeIgniter's query bui * mysql2 * pg * dblite -* node-firebird +* node-firebird (Not supported as of version 3.1.0, as the adapter is very difficult to test) ### Installation npm install ci-node-query - [![NPM](https://nodei.co/npm/ci-node-query.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/ci-node-query/) + +[![NPM](https://nodei.co/npm/ci-node-query.png?downloads=true&downloadRank=true)](https://nodei.co/npm/ci-node-query/) ### Basic use @@ -48,6 +49,20 @@ A node query builder for various SQL databases, based on CodeIgniter's query bui // Database module result handling }); + // As of version 3.1.0, you can also get promises + var queryPromise = query.select('foo') + .from('bar') + .where('x', 3) + .orWhere({y: 2}) + .join('baz', 'baz.boo = bar.foo', 'left') + .orderBy('x', 'DESC') + .limit(2, 3) + .get(); + + queryPromise.then(function(res) { + // Handle query results + }); + ### Security notes As of version 2, `where` and `having` type methods parse the values passed to look for function calls. While values passed are still passed as query parameters, take care to avoid passing these kinds of methods unfiltered input. SQL function arguments are not currently parsed, so they need to be properly escaped for the current database. @@ -55,6 +70,7 @@ As of version 2, `where` and `having` type methods parse the values passed to lo ### Additional help * Generated documentation is in the docs/ folder +* The API is documented in [API.md](./API.md) * `tests/query-builder-base.js` contains a lot of usage examples * The `tests/adapters` folder contains examples of how to set up a connection for the appropriate database library * The documentation generated for the latest dev build is also [Available](https://github.timshomepage.net/node-query/docs/) diff --git a/docs/index.html b/docs/index.html index 46bd3d6..5d51f99 100644 --- a/docs/index.html +++ b/docs/index.html @@ -22,6 +22,16 @@ class='col12 block field' type='text' />
+ + Firebird + + + Mysql + @@ -37,6 +47,11 @@ class='regular block'> #init + + Pg + @@ -232,12 +247,86 @@ class='regular block'> #whereNotIn + + Sqlite + + + close + + + close + + + execute + + + execute + + + execute + + + execute + + + execute + + + insertBatch + + + insertBatch + + + limit + + + limit +
+

+ Firebird +

+

Driver for Firebird databases

+ +
+
+

+ Mysql +

+

Driver for MySQL databases

+ +
+

NodeQuery

@@ -323,6 +412,13 @@
+
+

+ Pg +

+

Driver for PostgreSQL databases

+ +

QueryBuilder(Driver, Adapter) @@ -458,6 +554,8 @@

The Query Builder object, for chaining

+

Examples

+
query.from('tableName');
query.from('tableName t'); // Select the table with an alias
@@ -516,6 +614,8 @@

If no callback is passed, a promise is returned

+

Examples

+
query.get('table_name').then(promiseCallback); // Get all the rows in the table
query.get('table_name', 5, callback); // Get 5 rows from the table
query.get(callback); // Get the results of a query generated with other methods
@@ -934,7 +1034,8 @@

Examples

-
query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}], callbackFunction);
+
query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}], callbackFunction);
query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}])
+            .then(promiseCallback);
@@ -1391,7 +1492,7 @@ prefixed with 'OR NOT'

- #orWhereIn(key, val) + #orWhereIn(key, values)

Set a 'or where in' clause

@@ -1401,7 +1502,7 @@ prefixed with 'OR NOT'

- orWhereIn(key, val) + orWhereIn(key, values)

Set a 'or where in' clause

@@ -1414,7 +1515,7 @@ prefixed with 'OR NOT'

-
  • Array val +
  • Array values :
  • -
  • Array val +
  • Array values :

    the array of items to search in

    @@ -1655,6 +1756,8 @@ prefixed with 'OR NOT'

    The Query Builder object, for chaining

    +

    Examples

    +
    query.select('foo, bar'); // Select multiple fields with a string
    query.select(['foo', 'bar']); // Select multiple fileds with an array
  • @@ -1699,6 +1802,8 @@ prefixed with 'OR NOT'

    The Query Builder object, for chaining

    +

    Examples

    +
    query.set('foo', 'bar'); // Set a key, value pair
    query.set({foo:'bar'}); // Set with an object
    @@ -1800,7 +1905,7 @@ prefixed with 'OR NOT'

    - #whereIn(key, val) + #whereIn(key, values) +
    +

    + Sqlite +

    +

    Driver for Sqlite databases

    + +
    +
    +

    + close +

    +

    Close the current database connection

    + +

    Returns

    + void + +
    + +
    +
    +
    +

    + close +

    +

    Close the current database connection

    + +

    Returns

    + void + +
    + +
    +
    +
    +

    + execute(sql, params, [callback]) +

    +

    Run the sql query as a prepared statement

    + +

    Parameters

    +
      +
    • String sql + : +
      +

      The sql with placeholders

      + +
      +
    • +
    • Array params + : +
      +

      The values to insert into the query

      + +
      +
    • +
    • [Function] callback + : +
      +

      Callback to run when a response is recieved

      + +
      +
    • +
    +

    Returns

    + void or Promise + : +
    +

    Returns a promise if no callback is provided

    + +
    +
    +
    +

    + execute(sql, params, [callback]) +

    +

    Run the sql query as a prepared statement

    + +

    Parameters

    +
      +
    • String sql + : +
      +

      The sql with placeholders

      + +
      +
    • +
    • Array params + : +
      +

      The values to insert into the query

      + +
      +
    • +
    • [Function] callback + : +
      +

      Callback to run when a response is recieved

      + +
      +
    • +
    +

    Returns

    + void or Promise + : +
    +

    Returns a promise if no callback is provided

    + +
    +
    +
    +

    + execute(sql, params, [callback]) +

    +

    Run the sql query as a prepared statement

    + +

    Parameters

    +
      +
    • String sql + : +
      +

      The sql with placeholders

      + +
      +
    • +
    • Array params + : +
      +

      The values to insert into the query

      + +
      +
    • +
    • [Function] callback + : +
      +

      Callback to run when a response is recieved

      + +
      +
    • +
    +

    Returns

    + void or Promise + : +
    +

    Returns a promise if no callback is provided

    + +
    +
    +
    +

    + execute(sql, params, [callback]) +

    +

    Run the sql query as a prepared statement

    + +

    Parameters

    +
      +
    • String sql + : +
      +

      The sql with placeholders

      + +
      +
    • +
    • Array params + : +
      +

      The values to insert into the query

      + +
      +
    • +
    • [Function] callback + : +
      +

      Callback to run when a response is recieved

      + +
      +
    • +
    +

    Returns

    + void or Promise + : +
    +

    Returns a promise if no callback is provided

    + +
    +
    +
    +

    + execute(sql, params, [callback]) +

    +

    Run the sql query as a prepared statement

    + +

    Parameters

    +
      +
    • String sql + : +
      +

      The sql with placeholders

      + +
      +
    • +
    • Array params + : +
      +

      The values to insert into the query

      + +
      +
    • +
    • [Function] callback + : +
      +

      Callback to run when a response is recieved

      + +
      +
    • +
    +

    Returns

    + void or Promise + : +
    +

    Returns a promise if no callback is provided

    + +
    +
    +
    +

    + insertBatch(table, [data]) +

    +

    SQL to insert a group of rows +Override default to have better compatibility

    + +

    Parameters

    +
      +
    • String table + : +
      +

      The table to insert to

      + +
      +
    • +
    • [Array] data + : +
      +

      The array of object containing data to insert

      + +
      +
    • +
    +

    Returns

    + String + : +
    +

    The generated sql statement

    + +
    +
    +
    +

    + insertBatch +

    +

    SQL to insert a group of rows

    + +

    Returns

    + void + +
    + +
    +

    Throws

    + +
    +
    +

    + limit(origSql, limit, offset) +

    +

    Set the limit clause

    + +

    Parameters

    +
      +
    • String origSql + : +
      +

      SQL statement to modify

      + +
      +
    • +
    • Number limit + : +
      +

      Maximum number of rows to fetch

      + +
      +
    • +
    • Number or offset + : +
      +

      Number of rows to skip

      + +
      +
    • +
    +

    Returns

    + String + : +
    +

    Modified SQL statement

    + +
    +
    +
    +

    + limit(sql, limit, offset) +

    +

    Set the limit clause

    + +

    Parameters

    +
      +
    • String sql + : +
      +

      SQL statement to modify

      + +
      +
    • +
    • Number limit + : +
      +

      Maximum number of rows to fetch

      + +
      +
    • +
    • Number or offset + : +
      +

      Number of rows to skip

      + +
      +
    • +
    +

    Returns

    + String + : +
    +

    Modified SQL statement

    + +
    +
    diff --git a/gulpfile.js b/gulpfile.js index 23fc1b8..4e8376b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -89,9 +89,12 @@ gulp.task('sloc', () => gulp.src(SRC_FILES).pipe(sloc())); gulp.task('test-sloc', () => gulp.src(TEST_FILES).pipe(sloc())); gulp.task('docs', () => { - gulp.src(['lib/*.js']) + gulp.src(['lib/**/*.js']) .pipe(documentation({format: 'html'})) .pipe(gulp.dest('docs')); + gulp.src(['lib/*.js']) + .pipe(documentation({format: 'md'})) + .pipe(gulp.dest('.')); }); gulp.task('mocha', ['lint-tests', 'sloc'], () => { diff --git a/lib/QueryBuilder.js b/lib/QueryBuilder.js index f6fe67c..23a29cf 100755 --- a/lib/QueryBuilder.js +++ b/lib/QueryBuilder.js @@ -298,7 +298,6 @@ class QueryBuilder { /** * Reset the object state for a new query * - * @memberOf QueryBuilder * @return {void} */ resetQuery() { @@ -331,8 +330,9 @@ class QueryBuilder { /** * Specify rows to select in the query * - * @memberOf QueryBuilder * @param {String|Array} fields - The fields to select from the current table + * @example query.select('foo, bar'); // Select multiple fields with a string + * @example query.select(['foo', 'bar']); // Select multiple fileds with an array * @return {QueryBuilder} - The Query Builder object, for chaining */ select(fields) { @@ -367,6 +367,8 @@ class QueryBuilder { * Specify the database table to select from * * @param {String} tableName - The table to use for the current query + * @example query.from('tableName'); + * @example query.from('tableName t'); // Select the table with an alias * @return {QueryBuilder} - The Query Builder object, for chaining */ from(tableName) { @@ -535,11 +537,11 @@ class QueryBuilder { * Set a 'where in' clause * * @param {String} key - the field to search - * @param {Array} val - the array of items to search in + * @param {Array} values - the array of items to search in * @return {QueryBuilder} - The Query Builder object, for chaining */ - whereIn(key, val) { - this._whereIn(key, val, 'IN', 'AND'); + whereIn(key, values) { + this._whereIn(key, values, 'IN', 'AND'); return this; } @@ -547,11 +549,11 @@ class QueryBuilder { * Set a 'or where in' clause * * @param {String} key - the field to search - * @param {Array} val - the array of items to search in + * @param {Array} values - the array of items to search in * @return {QueryBuilder} - The Query Builder object, for chaining */ - orWhereIn(key, val) { - this._whereIn(key, val, 'IN', 'OR'); + orWhereIn(key, values) { + this._whereIn(key, values, 'IN', 'OR'); return this; } @@ -559,11 +561,11 @@ class QueryBuilder { * Set a 'where not in' clause * * @param {String} key - the field to search - * @param {Array} val - the array of items to search in + * @param {Array} values - the array of items to search in * @return {QueryBuilder} - The Query Builder object, for chaining */ - whereNotIn(key, val) { - this._whereIn(key, val, 'NOT IN', 'AND'); + whereNotIn(key, values) { + this._whereIn(key, values, 'NOT IN', 'AND'); return this; } @@ -571,11 +573,11 @@ class QueryBuilder { * Set a 'or where not in' clause * * @param {String} key - the field to search - * @param {Array} val - the array of items to search in + * @param {Array} values - the array of items to search in * @return {QueryBuilder} - The Query Builder object, for chaining */ - orWhereNotIn(key, val) { - this._whereIn(key, val, 'NOT IN', 'OR'); + orWhereNotIn(key, values) { + this._whereIn(key, values, 'NOT IN', 'OR'); return this; } @@ -584,6 +586,8 @@ class QueryBuilder { * * @param {String|Object} key - The key or object to use * @param {String} [val] - The value if using a scalar key + * @example query.set('foo', 'bar'); // Set a key, value pair + * @example query.set({foo:'bar'}); // Set with an object * @return {QueryBuilder} - The Query Builder object, for chaining */ set(/* $key, [$val] */) { @@ -750,6 +754,9 @@ class QueryBuilder { * @param {Number} [limit] - A limit for the query * @param {Number} [offset] - An offset for the query * @param {Function} [callback] - A callback for receiving the result + * @example query.get('table_name').then(promiseCallback); // Get all the rows in the table + * @example query.get('table_name', 5, callback); // Get 5 rows from the table + * @example query.get(callback); // Get the results of a query generated with other methods * @return {void|Promise} - If no callback is passed, a promise is returned */ get(/* [table], [limit], [offset], [callback] */) { @@ -793,6 +800,8 @@ class QueryBuilder { * @param {Array} data - The array of objects containing data rows to insert * @param {Function} [callback] - Callback for handling database response * @example query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}], callbackFunction); + * @example query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}]) + *.then(promiseCallback); * @return {void|Promise} - If no callback is passed, a promise is returned */ insertBatch(/* table, data, callback */) {