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' />
Driver for Firebird databases
- -Driver for MySQL databases
- -Driver for PostgreSQL databases
- -
+ #query(sql, [params], [callback])
+
+ Manually make an sql query +Returns a promise if no callback is provided
+ +Manually make an sql query + Returns a promise if no callback is provided
+ +string
sql
+ :
+ The sql to execute
+ +[array
]
params
+ :
+ The query parameters
+ +[function
]
callback
+ :
+ Optional callback
+ +void
or Promise
+ :
+ Returns a promise if no callback is supplied
+ +Driver for Sqlite databases
- -Close the current database connection
- -void
-
- Close the current database connection
- -void
-
- Run the sql query as a prepared statement
+Function to convert a callback function into a promise
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
void
or Promise
+ Promise
:
Returns a promise if no callback is provided
- -Run the sql query as a prepared statement
- -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
- -void
or Promise
- :
- Returns a promise if no callback is provided
- -Run the sql query as a prepared statement
- -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
- -void
or Promise
- :
- Returns a promise if no callback is provided
- -Run the sql query as a prepared statement
- -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
- -void
or Promise
- :
- Returns a promise if no callback is provided
- -Run the sql query as a prepared statement
- -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
- -void
or Promise
- :
- Returns a promise if no callback is provided
- -SQL to insert a group of rows -Override default to have better compatibility
- -String
table
- :
- The table to insert to
- -[Array
]
data
- :
- The array of object containing data to insert
- -String
- :
- The generated sql statement
- -SQL to insert a group of rows
- -void
-
- Error
: Set the limit clause
- -String
origSql
- :
- SQL statement to modify
- -Number
limit
- :
- Maximum number of rows to fetch
- -Number
or offset
- :
- Number of rows to skip
- -String
- :
- Modified SQL statement
- -Set the limit clause
- -String
sql
- :
- SQL statement to modify
- -Number
limit
- :
- Maximum number of rows to fetch
- -Number
or offset
- :
- Number of rows to skip
- -String
- :
- Modified SQL statement
+the new promise
promisify(fs.readFile)('hello.txt', 'utf8')
+.then(console.log)
+.catch(console.error)