|
|
|
@ -189,6 +189,11 @@ class Xapi {
|
|
|
|
|
.get(this.asyncMiddleware(this.count.bind(this))); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'distinct': |
|
|
|
|
this.app.route(routes[i]['routeUrl']) |
|
|
|
|
.get(this.asyncMiddleware(this.distinct.bind(this))); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'describe': |
|
|
|
|
this.app.route(routes[i]['routeUrl']) |
|
|
|
|
.get(this.asyncMiddleware(this.tableDescribe.bind(this))); |
|
|
|
@ -271,7 +276,7 @@ class Xapi {
|
|
|
|
|
* @param req |
|
|
|
|
* @param res |
|
|
|
|
* @param queryParamsObj : {query, params} |
|
|
|
|
* @param listType : 0:list, 1:nested, 2:findOne, 3:bulkRead |
|
|
|
|
* @param listType : 0:list, 1:nested, 2:findOne, 3:bulkRead, 4:distinct |
|
|
|
|
* |
|
|
|
|
* Updates query, params for query of type listType |
|
|
|
|
*/ |
|
|
|
@ -280,6 +285,10 @@ class Xapi {
|
|
|
|
|
queryParamsObj.query = 'select '; |
|
|
|
|
queryParamsObj.params = []; |
|
|
|
|
|
|
|
|
|
if (listType === 4) { //list type distinct
|
|
|
|
|
queryParamsObj.query += ' distinct ' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**************** select columns ****************/ |
|
|
|
|
if (req.query._groupby) { |
|
|
|
|
this.mysql.getColumnsForSelectStmtWithGrpBy(req.query, req.app.locals._tableName, queryParamsObj); |
|
|
|
@ -377,6 +386,19 @@ class Xapi {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async distinct(req, res) { |
|
|
|
|
|
|
|
|
|
let queryParamsObj = {} |
|
|
|
|
queryParamsObj.query = '' |
|
|
|
|
queryParamsObj.params = [] |
|
|
|
|
|
|
|
|
|
this.prepareListQuery(req, res, queryParamsObj, 4); |
|
|
|
|
|
|
|
|
|
let results = await this.mysql.exec(queryParamsObj.query, queryParamsObj.params); |
|
|
|
|
res.status(200).json(results); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async nestedList(req, res) { |
|
|
|
|
|
|
|
|
|
let queryParamsObj = {} |
|
|
|
|