|
|
@ -230,7 +230,7 @@ class Xsql { |
|
|
|
if (orderByCols[i][0] === '-') { |
|
|
|
if (orderByCols[i][0] === '-') { |
|
|
|
let len = orderByCols[i].length; |
|
|
|
let len = orderByCols[i].length; |
|
|
|
queryParamsObj.query += ' ?? DESC' |
|
|
|
queryParamsObj.query += ' ?? DESC' |
|
|
|
queryParamsObj.params.push(orderByCols[i].substring(1, len) ) |
|
|
|
queryParamsObj.params.push(orderByCols[i].substring(1, len)) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
queryParamsObj.query += ' ?? ASC' |
|
|
|
queryParamsObj.query += ' ?? ASC' |
|
|
|
queryParamsObj.params.push(orderByCols[i]) |
|
|
|
queryParamsObj.params.push(orderByCols[i]) |
|
|
@ -457,6 +457,7 @@ class Xsql { |
|
|
|
routes.push(this.prepareRoute(internal, 'get', apiPrefix, tableName + '/count', 'count')) |
|
|
|
routes.push(this.prepareRoute(internal, 'get', apiPrefix, tableName + '/count', 'count')) |
|
|
|
routes.push(this.prepareRoute(internal, 'get', apiPrefix, tableName + '/groupby', 'groupby')) |
|
|
|
routes.push(this.prepareRoute(internal, 'get', apiPrefix, tableName + '/groupby', 'groupby')) |
|
|
|
routes.push(this.prepareRoute(internal, 'get', apiPrefix, tableName + '/ugroupby', 'ugroupby')) |
|
|
|
routes.push(this.prepareRoute(internal, 'get', apiPrefix, tableName + '/ugroupby', 'ugroupby')) |
|
|
|
|
|
|
|
routes.push(this.prepareRoute(internal, 'get', apiPrefix, tableName + '/chart', 'chart')) |
|
|
|
routes.push(this.prepareRoute(internal, 'get', apiPrefix, tableName + '/aggregate', 'aggregate')) |
|
|
|
routes.push(this.prepareRoute(internal, 'get', apiPrefix, tableName + '/aggregate', 'aggregate')) |
|
|
|
routes.push(this.prepareRoute(internal, 'get', apiPrefix, tableName + '/findOne', 'findOne')) |
|
|
|
routes.push(this.prepareRoute(internal, 'get', apiPrefix, tableName + '/findOne', 'findOne')) |
|
|
|
routes.push(this.prepareRoute(internal, 'post', apiPrefix, tableName, 'create')) |
|
|
|
routes.push(this.prepareRoute(internal, 'post', apiPrefix, tableName, 'create')) |
|
|
@ -499,6 +500,76 @@ class Xsql { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getChartQueryAndParamsFromStepArray(tableName, columnName, stepArray) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let obj = {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj.query = '' |
|
|
|
|
|
|
|
obj.params = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (stepArray.length && stepArray.length >= 2) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let params = [tableName, columnName, stepArray[0], stepArray[1]] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < stepArray.length - 1; i = i + 1) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj.query = obj.query + dataHelp.getChartQuery(); |
|
|
|
|
|
|
|
if (i + 2 < stepArray.length) { |
|
|
|
|
|
|
|
obj.query = obj.query + ' union ' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i) { |
|
|
|
|
|
|
|
stepArray[i] = stepArray[i] + 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj.params.push((stepArray[i]) + ' to ' + stepArray[i + 1]) |
|
|
|
|
|
|
|
obj.params.push(columnName) |
|
|
|
|
|
|
|
obj.params.push(tableName) |
|
|
|
|
|
|
|
obj.params.push(columnName) |
|
|
|
|
|
|
|
obj.params.push(stepArray[i]) |
|
|
|
|
|
|
|
obj.params.push(stepArray[i + 1]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//console.log('step spread query', obj);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return obj; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getChartQueryAndParamsFromMinMaxStddev(tableName, columnName, min, max, stddev) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let stepArray = dataHelp.getRange(min, max, stddev) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//console.log('steparray', stepArray);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let obj = this.getChartQueryAndParamsFromStepArray(tableName, columnName, stepArray) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//console.log('steparray', obj);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return obj |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getChartQueryAndParamsFromMinMaxStep(tableName, columnName, min, max, step) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let stepArray = dataHelp.getRangeSimple(min, max, step) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//console.log('steparray', stepArray);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let obj = this.getChartQueryAndParamsFromStepArray(tableName, columnName, stepArray) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//console.log('steparray', obj);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return obj |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|