chaosrouter
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -33,2 +33,5 @@ | ||
} | ||
function repeat(str, num) { | ||
return new Array( num + 1 ).join( str ); | ||
} | ||
function is_dict(d) { | ||
@@ -265,3 +268,25 @@ return d.constructor.name == 'Object'; | ||
this.joins = this.config['.join']; | ||
this.columns = this.config['.columns']; | ||
if (this.columns === undefined) { | ||
var columns = '*'; | ||
} | ||
else { | ||
var columns = []; | ||
for(var i=0; i<this.columns.length; i++) { | ||
var column = this.columns[i]; | ||
if (typeof column === 'string') | ||
columns.push(column); | ||
else if (Array.isArray(column) && column.length === 2) { | ||
var c = column[0]; | ||
var a = column[1] | ||
var nt = Math.ceil( Math.max( (31-c.length)/8, 0 ) ); | ||
var t = repeat("\t", nt); | ||
var f = "{0}{tabs}AS '{1}'"; | ||
columns.push(format(f, c, a, { tabs: t })); | ||
} | ||
} | ||
columns = columns.join(",\n "); | ||
} | ||
if (this.joins === undefined) { | ||
@@ -280,15 +305,18 @@ var joins = ''; | ||
var c2 = format.apply( this, join[2] ) | ||
joins.push(format("{0} ON {1} = {2}", t,c1,c2)) | ||
var nt = Math.ceil( Math.max( (25-t.length)/8, 0 ) ); | ||
var nt2 = Math.ceil( Math.max( (37-c1.length)/8, 0 ) ); | ||
var tabs = repeat("\t", nt); | ||
var tabs2 = repeat("\t", nt2); | ||
joins.push(format("{0}{tabs}ON {1}{tabs2}= {2}", t,c1,c2, {tabs: tabs, tabs2: tabs2})) | ||
} | ||
joins = " LEFT JOIN " + joins.join(" LEFT JOIN "); | ||
joins = "\n LEFT JOIN " + joins.join("\n LEFT JOIN "); | ||
} | ||
if (this.where === undefined) { | ||
if (this.where === undefined) | ||
var where = ''; | ||
} | ||
else { | ||
var where = format(" WHERE {0} ", fill(this.where, this.args)); | ||
} | ||
var query = format(" SELECT * FROM {table}{join}{where} ", { | ||
else | ||
var where = format("\n WHERE {0} ", fill(this.where, this.args)); | ||
var query = format(" SELECT {columns}\n FROM {table}{join}{where} ", { | ||
'table': this.table, | ||
'columns': columns, | ||
'join': joins, | ||
@@ -344,6 +372,7 @@ 'where': where | ||
var query = self.query(); | ||
var q_callback = function(err, all) { | ||
if(err !== undefined && err !== null) | ||
if(err !== undefined && err !== null) { | ||
err.query = query; | ||
return f(err); | ||
} | ||
var result = structure === null | ||
@@ -350,0 +379,0 @@ ? all |
{ | ||
"name": "chaosrouter", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "ERROR: No README data found!", | ||
@@ -21,3 +21,4 @@ "main": "chaosrouter.js", | ||
"dependencies": { | ||
"restruct-data": "^0.1.7" | ||
"promise": "^7.0.4", | ||
"restruct-data": "^0.1.9" | ||
}, | ||
@@ -24,0 +25,0 @@ "devDependencies": {}, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11172
388
2
+ Addedpromise@^7.0.4
+ Addedasap@2.0.6(transitive)
+ Addedpromise@7.3.1(transitive)
Updatedrestruct-data@^0.1.9