From 9c7b93e7e15ebb88661c3697d498288a6a1e852f Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Fri, 12 Feb 2016 11:40:49 -0500 Subject: [PATCH] Update documentation --- API.md | 31 +++ docs/index.html | 495 +++++++----------------------------------------- 2 files changed, 102 insertions(+), 424 deletions(-) diff --git a/API.md b/API.md index 7cfc697..7885a1c 100644 --- a/API.md +++ b/API.md @@ -366,6 +366,19 @@ Order the results by the selected field(s) Returns **QueryBuilder** The Query Builder object, for chaining +## query + +Manually make an sql query +Returns a promise if no callback is provided + +**Parameters** + +- `sql` **string** The sql to execute +- `params` **[array]** The query parameters +- `callback` **[function]** Optional callback + +Returns **void or Promise** Returns a promise if no callback is supplied + ## resetQuery Reset the object state for a new query @@ -477,3 +490,21 @@ Set a 'where not in' clause - `values` **Array** the array of items to search in Returns **QueryBuilder** The Query Builder object, for chaining + +# promisify + +Function to convert a callback function into a promise + +**Parameters** + +- `fn` **Function** the callback function to convert + +**Examples** + +```javascript +promisify(fs.readFile)('hello.txt', 'utf8') +.then(console.log) +.catch(console.error) +``` + +Returns **Promise** the new promise diff --git a/docs/index.html b/docs/index.html index 5d51f99..7621d25 100644 --- a/docs/index.html +++ b/docs/index.html @@ -22,16 +22,6 @@ class='col12 block field' type='text' />
- - Firebird - - - Mysql - @@ -47,11 +37,6 @@ class='regular block'> #init - - Pg - @@ -202,6 +187,11 @@ class='regular block'> #orderBy + + #query + @@ -248,64 +238,9 @@ #whereNotIn - Sqlite - - - close - - - close - - - execute - - - execute - - - execute - - - execute - - - execute - - - insertBatch - - - insertBatch - - - limit - - - limit + promisify
@@ -313,20 +248,6 @@
-

- Firebird -

-

Driver for Firebird databases

- -
-
-

- Mysql -

-

Driver for MySQL databases

- -
-

NodeQuery

@@ -412,13 +333,6 @@
-
-

- Pg -

-

Driver for PostgreSQL databases

- -

QueryBuilder(Driver, Adapter) @@ -1696,6 +1610,59 @@ prefixed with 'OR NOT'

+
+ + + #query(sql, [params], [callback]) + +
+

Manually make an sql query +Returns a promise if no callback is provided

+ +
+
+
+
+

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

+

Manually make an sql query + Returns a promise if no callback is provided

+ +

Parameters

+
    +
  • string sql + : +
    +

    The sql to execute

    + +
    +
  • +
  • [array] params + : +
    +

    The query parameters

    + +
    +
  • +
  • [function] callback + : +
    +

    Optional callback

    + +
    +
  • +
+

Returns

+ void or Promise + : +
+

Returns a promise if no callback is supplied

+ +
+
+
+
@@ -2066,352 +2033,32 @@ prefixed with 'OR NOT'

-

- Sqlite +

+ promisify(fn)

-

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

+

Function to convert a callback function into a promise

Parameters

    -
  • String sql +
  • Function fn :
    -

    The sql with placeholders

    - -
    -
  • -
  • Array params - : -
    -

    The values to insert into the query

    - -
    -
  • -
  • [Function] callback - : -
    -

    Callback to run when a response is recieved

    +

    the callback function to convert

Returns

- void or Promise + 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

+

the new promise

+

Examples

+
promisify(fs.readFile)('hello.txt', 'utf8')
+.then(console.log)
+.catch(console.error)