Update docs
This commit is contained in:
parent
83af1d3946
commit
16cab60352
@ -85,6 +85,7 @@ var helpers = require('./helpers');
|
||||
var d = {
|
||||
identifierChar: '"',
|
||||
tablePrefix: null,
|
||||
hasTruncate: true,
|
||||
|
||||
/**
|
||||
* Low level function for naive quoting of strings
|
||||
@ -214,6 +215,22 @@ var d = {
|
||||
}
|
||||
|
||||
return raw;
|
||||
},
|
||||
|
||||
/**
|
||||
* SQL to truncate the passed table
|
||||
*
|
||||
* @param {String} table
|
||||
* @return {String} - sql
|
||||
*/
|
||||
truncate: function(table) {
|
||||
var sql = (d.hasTruncate)
|
||||
? 'TRUNCATE '
|
||||
: 'DELETE FROM ';
|
||||
|
||||
sql += d.quoteTable(table);
|
||||
|
||||
return sql;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -309,7 +309,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-396">line 396</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-399">line 399</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -554,7 +554,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-738">line 738</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-741">line 741</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -745,7 +745,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-849">line 849</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-860">line 860</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -944,7 +944,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-827">line 827</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-838">line 838</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -1145,7 +1145,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-811">line 811</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-822">line 822</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -1336,7 +1336,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-838">line 838</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-849">line 849</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -1431,7 +1431,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-343">line 343</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-346">line 346</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -1578,7 +1578,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-620">line 620</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-623">line 623</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -1665,7 +1665,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-719">line 719</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-722">line 722</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -1752,7 +1752,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-683">line 683</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-686">line 686</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -1937,7 +1937,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-469">line 469</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-472">line 472</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -2147,7 +2147,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-761">line 761</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-764">line 764</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -2373,7 +2373,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-595">line 595</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-598">line 598</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -2599,7 +2599,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-418">line 418</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-421">line 421</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -2778,7 +2778,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-671">line 671</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-674">line 674</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -3004,7 +3004,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-431">line 431</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-434">line 434</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -3195,7 +3195,7 @@
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-643">line 643</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-646">line 646</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -3283,7 +3283,7 @@ prefixed with 'OR'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-696">line 696</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-699">line 699</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -3468,7 +3468,7 @@ prefixed with 'OR'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-483">line 483</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-486">line 486</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -3694,7 +3694,7 @@ prefixed with 'OR'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-444">line 444</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-447">line 447</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -3782,7 +3782,7 @@ prefixed with 'OR NOT'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-708">line 708</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-711">line 711</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -4008,7 +4008,7 @@ prefixed with 'OR NOT'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-457">line 457</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-460">line 460</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -4193,7 +4193,7 @@ prefixed with 'OR NOT'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-509">line 509</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-512">line 512</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -4352,7 +4352,7 @@ prefixed with 'OR NOT'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-533">line 533</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-536">line 536</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -4511,7 +4511,7 @@ prefixed with 'OR NOT'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-557">line 557</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-560">line 560</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -4650,7 +4650,7 @@ prefixed with 'OR NOT'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-362">line 362</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-365">line 365</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -4832,7 +4832,7 @@ prefixed with 'OR NOT'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-569">line 569</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-572">line 572</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -5042,7 +5042,7 @@ prefixed with 'OR NOT'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-779">line 779</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-782">line 782</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -5227,7 +5227,7 @@ prefixed with 'OR NOT'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-497">line 497</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-500">line 500</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -5386,7 +5386,7 @@ prefixed with 'OR NOT'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-521">line 521</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-524">line 524</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -5545,7 +5545,7 @@ prefixed with 'OR NOT'</p>
|
||||
<ul class="dummy">
|
||||
<li>
|
||||
<a href="query-builder.js.html">query-builder.js</a>,
|
||||
<a href="query-builder.js.html#sunlight-1-line-545">line 545</a>
|
||||
<a href="query-builder.js.html#sunlight-1-line-548">line 548</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
@ -100,6 +100,9 @@ var QueryBuilder = function(driver, adapter) {
|
||||
|
||||
var parser = require('./query-parser')(driver);
|
||||
|
||||
this.driver = driver;
|
||||
this.adapter = adapter;
|
||||
|
||||
/**
|
||||
* "Private" methods
|
||||
*
|
||||
@ -851,13 +854,14 @@ var QueryBuilder = function(driver, adapter) {
|
||||
* @param {Function} callback - Callback for handling response from the database
|
||||
* @return void
|
||||
*/
|
||||
this.update = function(table, data, callback) {
|
||||
if (data) {
|
||||
this.set(data);
|
||||
this.update = function(/*table, data, callback*/) {
|
||||
var args = getArgs('table:string, [data]:object, callback:function', arguments);
|
||||
if (args.data) {
|
||||
this.set(args.data);
|
||||
}
|
||||
|
||||
// Run the query
|
||||
_p.run('update', table, callback);
|
||||
_p.run('update', args.table, args.callback);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -867,9 +871,16 @@ var QueryBuilder = function(driver, adapter) {
|
||||
* @param {Function} callback - Callback for handling response from the database
|
||||
* @return void
|
||||
*/
|
||||
this['delete'] = function (table, callback) {
|
||||
this['delete'] = function (/*table, [where], callback*/) {
|
||||
var args = getArgs('table:string, [where], callback:function', arguments);
|
||||
|
||||
if (args.where)
|
||||
{
|
||||
this.where(args.where);
|
||||
}
|
||||
|
||||
// Run the query
|
||||
_p.run('delete', table, callback);
|
||||
_p.run('delete', args.table, args.callback);
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user