Browse Source

Feature addition: group by and having in query params

version : 0.1.0
pull/13/head
oof1lab 7 years ago
parent
commit
a6d098cd5b
  1. 8
      README.md
  2. 20
      bin/index.js
  3. 16
      index.js
  4. 4
      lib/util/cmd.helper.js
  5. 8
      lib/util/data.helper.js
  6. 2
      lib/util/whereClause.helper.js
  7. 76
      lib/xapi.js
  8. 38
      lib/xsql.js
  9. 4
      package-lock.json
  10. 2
      package.json
  11. 265
      tests/tests.js

8
README.md

@ -29,7 +29,7 @@ xmysql -h localhost -u mysqlUsername -p mysqlPassword -d databaseName
http://localhost:3000
```
That's it!
That is it! Happy hackery!
## Features
* Generates API for **ANY** MySql database
@ -40,15 +40,15 @@ That's it!
* Sorting
* Column filtering - Fields
* Row filtering - Where
* Group By
* Group By, Order By
* Group By, Having (as query params)
* Group By (as a separate route)
* Aggregate functions
* Relations
* Run dynamic queries
* Upload single file
* Upload multiple files
* Download file
* Group By, Having - Work in Progress - :racehorse::racehorse:
Use HTTP clients like [Postman](https://www.getpostman.com/) or [similar tools](https://chrome.google.com/webstore/search/http%20client?_category=apps) to invoke REST API calls

20
bin/index.js

@ -1,13 +1,13 @@
#! /usr/bin/env node
const morgan = require('morgan');
const bodyParser = require('body-parser');
const express = require('express');
const sqlConfig = require('commander');
const mysql = require('mysql');
const dataHelp = require('./lib/util/data.helper.js');
const Xapi = require('../lib/xapi.js');
const cmdargs = require('../lib/util/cmd.helper.js');
const Xapi = require('./lib/xapi.js');
const cmdargs = require('./lib/util/cmd.helper.js');
cmdargs.handle(sqlConfig)
@ -29,11 +29,25 @@ let mysqlPool = mysql.createPool(sqlConfig);
/**************** START : setup Xapi ****************/
console.log('');
console.log('');
console.log(' Generating APIs at speed of your thoughts.. ');
console.log('');
console.log('');
let t = process.hrtime();
let moreApis = new Xapi(sqlConfig,mysqlPool,app);
moreApis.init((err, results) => {
app.listen(sqlConfig.portNumber)
var t1 = process.hrtime(t);
var t2 = t1[0]+t1[1]/1000000000
console.log('| |');
console.log("| xmysql took : %d seconds",dataHelp.round(t2,1));
console.log('| |');
console.log(' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ');
})
/**************** END : setup Xapi ****************/

16
index.js

@ -1,10 +1,10 @@
#! /usr/bin/env node
const morgan = require('morgan');
const bodyParser = require('body-parser');
const express = require('express');
const sqlConfig = require('commander');
const mysql = require('mysql');
const dataHelp = require('./lib/util/data.helper.js');
const Xapi = require('./lib/xapi.js');
const cmdargs = require('./lib/util/cmd.helper.js');
@ -29,11 +29,25 @@ let mysqlPool = mysql.createPool(sqlConfig);
/**************** START : setup Xapi ****************/
console.log('');
console.log('');
console.log(' Generating APIs at speed of your thoughts.. ');
console.log('');
console.log('');
let t = process.hrtime();
let moreApis = new Xapi(sqlConfig,mysqlPool,app);
moreApis.init((err, results) => {
app.listen(sqlConfig.portNumber)
var t1 = process.hrtime(t);
var t2 = t1[0]+t1[1]/1000000000
console.log('| |');
console.log("| xmysql took : %d seconds",dataHelp.round(t2,1));
console.log('| |');
console.log(' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ');
})
/**************** END : setup Xapi ****************/

4
lib/util/cmd.helper.js

@ -11,7 +11,7 @@ program.on('--help', () => {
})
program
.version('0.0.9')
.version('0.1.0')
.option('-h, --host <n>', 'hostname')
.option('-d, --database <n>', 'database schema name')
.option('-u, --user <n>', 'username of database / root by default')
@ -62,7 +62,7 @@ exports.handle = program => {
if (program.database && program.host && program.user) {
console.log('Starting server at:', 'http://' + program.host + ':' + program.portNumber)
//console.log('Starting server at:', 'http://' + program.host + ':' + program.portNumber)
} else {
processInvalidArguments(program)
process.exit(1)

8
lib/util/data.helper.js

@ -35,6 +35,14 @@ exports.findObjectInArrayByKey = (key, value, objArray) => {
};
exports.round = function(number, precision) {
var factor = Math.pow(10, precision);
var tempNumber = number * factor;
var roundedTempNumber = Math.round(tempNumber);
return roundedTempNumber / factor;
};
exports.getSchemaQuery = function () {
return 'select c.table_name, c.column_name, c.ordinal_position,c.column_key,c.is_nullable, c.data_type, c.column_type,c.extra,c.privileges, ' +
'c.column_comment,c.column_default,c.data_type,c.character_maximum_length, ' +

2
lib/util/whereClause.helper.js

@ -119,7 +119,7 @@ function getLogicalOperator(operator) {
}
exports.getWhereClause = function (whereInQueryParams) {
exports.getConditionClause = function (whereInQueryParams, condType = 'where') {
let whereQuery = '';
let whereParams = [];

76
lib/xapi.js

@ -3,6 +3,7 @@
var Xsql = require('./xsql.js');
var multer = require('multer');
var path = require('path');
const colors = require('colors');
//define class
class Xapi {
@ -98,6 +99,10 @@ class Xapi {
setupRoutes() {
let stat = {}
stat.tables = 0
stat.apis = 0
// show routes for database schema
this.app.get('/', this.asyncMiddleware(this.root.bind(this)))
@ -111,11 +116,15 @@ class Xapi {
let resources = [];
resources = this.mysql.getSchemaRoutes(true, '/api/');
stat.tables += resources.length
// iterate over each resource
for (var j = 0; j < resources.length; ++j) {
let routes = resources[j]['routes'];
stat.apis += resources[j]['routes'].length
// iterate over rach routes in resource and map function
for (var i = 0; i < routes.length; ++i) {
@ -194,7 +203,19 @@ class Xapi {
this.app.get('/download', this.downloadFile.bind(this));
/**************** END : multer routes ****************/
stat.api += 4;
}
let statStr = ' Generated: ' + stat.apis + ' REST APIs for ' + stat.tables + ' tables '
console.log(' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ');
console.log('| |');
console.log('| |');
console.log('| ' + statStr);
console.log('| |');
console.log('| |');
console.log(' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ');
}
async create(req, res) {
@ -215,15 +236,27 @@ class Xapi {
let queryParamsObj = {}
queryParamsObj.query = '';
queryParamsObj.params = [];
let cols = ''
if (req.query._groupby) {
cols = this.mysql.getColumnsForSelectStmtWithGrpBy(req.query, req.app.locals._tableName);
} else {
cols = this.mysql.getColumnsForSelectStmt(req.app.locals._tableName, req.query);
}
let cols = this.mysql.getColumnsForSelectStmt(req.app.locals._tableName, req.query);
/**************** tableName ****************/
queryParamsObj.query = 'select ' + cols + ' from ?? ';
queryParamsObj.params.push(req.app.locals._tableName);
/**************** where clause ****************/
this.mysql.getWhereClause(req.query, req.app.locals._tableName, queryParamsObj,' where ');
this.mysql.getWhereClause(req.query._where, req.app.locals._tableName, queryParamsObj, ' where ');
/**************** group by ****************/
this.mysql.getGroupByClause(req.query._groupby, req.app.locals._tableName, queryParamsObj);
/**************** having ****************/
this.mysql.getHavingClause(req.query._having, req.app.locals._tableName, queryParamsObj);
/**************** order clause ****************/
queryParamsObj.query += this.mysql.getOrderByClause(req.query, req.app.locals._tableName);
@ -241,12 +274,17 @@ class Xapi {
async nestedList(req, res) {
let cols = ''
let queryParamsObj = {}
queryParamsObj.query = '';
queryParamsObj.params = [];
/**************** tableName ****************/
let cols = this.mysql.getColumnsForSelectStmt(req.app.locals._childTable, req.query);
if (req.query._groupby) {
cols = this.mysql.getColumnsForSelectStmtWithGrpBy(req.query, req.app.locals._tableName);
} else {
cols = this.mysql.getColumnsForSelectStmt(req.app.locals._tableName, req.query);
}
queryParamsObj.query = 'select ' + cols + ' from ?? where ';
queryParamsObj.params.push(req.app.locals._childTable);
@ -263,7 +301,13 @@ class Xapi {
queryParamsObj.query += whereClause;
/**************** where conditions in query ****************/
this.mysql.getWhereClause(req.query, req.app.locals._tableName, queryParamsObj, ' and ');
this.mysql.getWhereClause(req.query._where, req.app.locals._tableName, queryParamsObj, ' and ');
/**************** group by ****************/
this.mysql.getGroupByClause(req.query._groupby, req.app.locals._tableName, queryParamsObj);
/**************** having ****************/
this.mysql.getHavingClause(req.query._having, req.app.locals._tableName, queryParamsObj);
/**************** order clause ****************/
queryParamsObj.query = queryParamsObj.query + this.mysql.getOrderByClause(req.query, req.app.locals._parentTable);
@ -437,22 +481,30 @@ class Xapi {
async groupBy(req, res) {
if (req.query && req.query._fields) {
let query = 'select ' + req.query._fields + ',count(*) as count from ?? group by ' + req.query._fields;
let params = [];
let tableName = req.app.locals._tableName;
params.push(tableName);
let queryParamsObj = {}
queryParamsObj.query = '';
queryParamsObj.params = [];
if (!req.query.sort) {
queryParamsObj.query = 'select ' + req.query._fields + ',count(*) as _count from ?? group by ' + req.query._fields;
let tableName = req.app.locals._tableName;
queryParamsObj.params.push(tableName);
if (!req.query._sort) {
req.query._sort = {}
req.query._sort = '-count'
req.query._sort = '-_count'
}
query = query + this.mysql.getOrderByClause(req.query, tableName);
/**************** where clause ****************/
this.mysql.getHavingClause(req.query._having, req.app.locals._tableName, queryParamsObj, ' having ');
var results = await this.mysql.exec(query, params);
queryParamsObj.query = queryParamsObj.query + this.mysql.getOrderByClause(req.query, tableName);
//console.log(queryParamsObj.query, queryParamsObj.params);
var results = await this.mysql.exec(queryParamsObj.query, queryParamsObj.params);
res.status(200).json(results);
} else {
res.status(400).json({message: 'Missing _fields query params eg: /api/tableName/groupby?_fields=column1'})
}

38
lib/xsql.js

@ -6,7 +6,7 @@ const whereHelp = require('./util/whereClause.helper.js');
const assert = require('assert')
//define class
//define class§
class Xsql {
constructor(sqlConfig, pool) {
@ -173,13 +173,36 @@ class Xsql {
}
getWhereClause(queryparams, tableName, queryParamsObj, appendToWhere) {
getGroupByClause(_groupby, tableName, queryParamsObj) {
if(_groupby){
queryParamsObj.query += ' group by ' + _groupby + ' '
return _groupby
}
let addWhereStr = ''
}
getHavingClause(_having, tableName, queryParamsObj) {
if (queryparams && queryparams._where) {
if (_having) {
let whereClauseObj = whereHelp.getWhereClause(queryparams._where)
let whereClauseObj = whereHelp.getConditionClause(_having,'having')
if (whereClauseObj.err === 0) {
queryParamsObj.query = queryParamsObj.query + ' having ' + whereClauseObj.query;
queryParamsObj.params = queryParamsObj.params.concat(whereClauseObj.params)
}
//console.log('> > > after where clause filling up:', queryParamsObj.query, queryParamsObj.params);
}
}
getWhereClause(queryparams, tableName, queryParamsObj, appendToWhere) {
if (queryparams) {
let whereClauseObj = whereHelp.getConditionClause(queryparams)
if (whereClauseObj.err === 0) {
queryParamsObj.query = queryParamsObj.query + appendToWhere + whereClauseObj.query;
@ -191,6 +214,7 @@ class Xsql {
}
getOrderByClause(queryparams, tableName) {
//defaults
@ -220,6 +244,10 @@ class Xsql {
return orderBy
}
getColumnsForSelectStmtWithGrpBy(reqQueryParams, tableName) {
return reqQueryParams._groupby + ',count(1) as _count'
}
getColumnsForSelectStmt(tableName, reqQueryParams) {
let table = this.metaDb.tables[tableName];

4
package-lock.json generated

@ -1,6 +1,6 @@
{
"name": "More-Apis",
"version": "0.0.2",
"name": "xmysql",
"version": "0.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

2
package.json

@ -1,6 +1,6 @@
{
"name": "xmysql",
"version": "0.0.9",
"version": "0.1.0",
"description": "One command to generate REST APIs for any MySql database",
"main": "index.js",
"scripts": {

265
tests/tests.js

@ -565,8 +565,6 @@ describe('xmysql : tests', function () {
});
});
http://localhost:3000/api/payments?_where=(checkNumber,eq,JM555205)~or(checkNumber,eq,OM314933)
it('GET /api/payments?_where=(checkNumber,eq,JM555205)~or(checkNumber,eq,OM314933) should PASS', function (done) {
//post to an url with data
@ -733,7 +731,7 @@ describe('xmysql : tests', function () {
}
//validate response
res.body[0]['city'].should.be.equals("NYC")
res.body[0]['city'].should.be.equals("Aachen")
res.body.length.should.be.equals(95)
return done();
@ -741,6 +739,166 @@ describe('xmysql : tests', function () {
});
});
it('GET /api/offices/1/employees?_groupby=jobTitle&_having=(_count,gt,1) should PASS', function (done) {
//post to an url with data
agent.get('/api/offices/1/employees?_groupby=jobTitle&_having=(_count,gt,1)') //enter url
.expect(200)//200 for success 4xx for failure
.end(function (err, res) {
// Handle /api/v error
if (err) {
return done(err);
}
//validate response
res.body[0]['_count'].should.be.equals(2)
res.body.length.should.be.equals(1)
return done();
});
});
it('GET /api/offices/1/employees?_groupby=jobTitle should PASS', function (done) {
//post to an url with data
agent.get('/api/offices/1/employees?_groupby=jobTitle') //enter url
.expect(200)//200 for success 4xx for failure
.end(function (err, res) {
// Handle /api/v error
if (err) {
return done(err);
}
//validate response
res.body[0]['jobTitle'].should.be.equals("President")
res.body.length.should.be.equals(5)
return done();
});
});
it('GET /api/offices?_groupby=country should PASS', function (done) {
//post to an url with data
agent.get('/api/offices?_groupby=country') //enter url
.expect(200)//200 for success 4xx for failure
.end(function (err, res) {
// Handle /api/v error
if (err) {
return done(err);
}
//validate response
res.body[0]['country'].should.be.equals("Australia")
res.body.length.should.be.equals(5)
return done();
});
});
it('GET /api/offices?_groupby=country&_sort=country should PASS', function (done) {
//post to an url with data
agent.get('/api/offices?_groupby=country&_sort=-country') //enter url
.expect(200)//200 for success 4xx for failure
.end(function (err, res) {
// Handle /api/v error
if (err) {
return done(err);
}
//validate response
res.body[0]['country'].should.be.equals("USA")
return done();
});
});
it('GET /api/offices?_groupby=country&_sort=_count should PASS', function (done) {
//post to an url with data
agent.get('/api/offices?_groupby=country&_sort=_count') //enter url
.expect(200)//200 for success 4xx for failure
.end(function (err, res) {
// Handle /api/v error
if (err) {
return done(err);
}
//validate response
res.body[0]['country'].should.be.equals("UK")
return done();
});
});
it('GET /api/offices?_groupby=country&_sort=-_count should PASS', function (done) {
//post to an url with data
agent.get('/api/offices?_groupby=country&_sort=-_count') //enter url
.expect(200)//200 for success 4xx for failure
.end(function (err, res) {
// Handle /api/v error
if (err) {
return done(err);
}
//validate response
res.body[0]['country'].should.be.equals("USA")
return done();
});
});
it('GET /api/offices/groupby?_fields=country&_having=(_count,gt,1) should PASS', function (done) {
//post to an url with data
agent.get('/api/offices/groupby?_fields=country&_having=(_count,gt,1)') //enter url
.expect(200)//200 for success 4xx for failure
.end(function (err, res) {
// Handle /api/v error
if (err) {
return done(err);
}
//validate response
res.body[0]['country'].should.be.equals("USA")
return done();
});
});
it('GET /api/offices?_groupby=country&_having=(_count,gt,1) should PASS', function (done) {
//post to an url with data
agent.get('/api/offices?_groupby=country&_having=(_count,gt,1)') //enter url
.expect(200)//200 for success 4xx for failure
.end(function (err, res) {
// Handle /api/v error
if (err) {
return done(err);
}
//validate response
res.body[0]['_count'].should.be.equals(3)
return done();
});
});
it('GET /api/offices/groupby?_fields=country should PASS', function (done) {
//post to an url with data
@ -774,8 +932,8 @@ describe('xmysql : tests', function () {
}
//validate response
res.body[0]['country'].should.be.equals("Australia")
res.body[0]['city'].should.be.equals("Sydney")
res.body[0]['country'].should.be.equals("USA")
res.body[0]['city'].should.be.equals("NYC")
res.body.length.should.be.equals(7)
return done();
@ -833,9 +991,7 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(abc,eq,1234) should PASS', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(abc,eq,1234)')
var err = whereClause.getConditionClause('(abc,eq,1234)')
err.err.should.be.equal(0)
err.query.should.be.equal('(??=?)')
@ -851,9 +1007,7 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(abc,ne,1234) should PASS', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(abc,ne,1234)')
var err = whereClause.getConditionClause('(abc,ne,1234)')
err.err.should.be.equal(0)
err.query.should.be.equal('(??!=?)')
@ -869,9 +1023,8 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(abc,lt,1234) should PASS', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(abc,lt,1234)')
var err = whereClause.getConditionClause('(abc,lt,1234)')
err.err.should.be.equal(0)
err.query.should.be.equal('(??<?)')
@ -886,9 +1039,7 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(abc,lte,1234) should PASS', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(abc,lte,1234)')
var err = whereClause.getConditionClause('(abc,lte,1234)')
err.err.should.be.equal(0)
err.query.should.be.equal('(??<=?)')
@ -903,9 +1054,8 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(abc,gt,1234) should PASS', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(abc,gt,1234)')
var err = whereClause.getConditionClause('(abc,gt,1234)')
err.err.should.be.equal(0)
err.query.should.be.equal('(??>?)')
@ -920,9 +1070,8 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(abc,gte,1234) should PASS', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(abc,gte,1234)')
var err = whereClause.getConditionClause('(abc,gte,1234)')
err.err.should.be.equal(0)
err.query.should.be.equal('(??>=?)')
@ -940,7 +1089,7 @@ describe('xmysql : tests', function () {
//
// var query = ''
// var params = []
// var err = whereClause.getWhereClause('(abc,like,1234)')
// var err = whereClause.getConditionClause('(abc,like,1234)')
//
// err.err.should.be.equal(0)
// err.query.should.be.equal('(?? like ?)')
@ -958,7 +1107,7 @@ describe('xmysql : tests', function () {
//
// var query = ''
// var params = []
// var err = whereClause.getWhereClause('(abc,nlike,1234)')
// var err = whereClause.getConditionClause('(abc,nlike,1234)')
//
// err.err.should.be.equal(0)
// err.query.should.be.equal('(?? not like ?)')
@ -973,9 +1122,8 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=abc,eq,1234) should FAIL', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('abc,eq,1234)')
var err = whereClause.getConditionClause('abc,eq,1234)')
err.err.should.be.equal(1)
err.query.should.be.equal('')
@ -989,9 +1137,8 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(abc,eq,1234 should FAIL', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(abc,eq,1234')
var err = whereClause.getConditionClause('(abc,eq,1234')
err.err.should.be.equal(1)
err.query.should.be.equal('')
@ -1005,9 +1152,7 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(abc,eq1234) should FAIL', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(abc,eq1234)')
var err = whereClause.getConditionClause('(abc,eq1234)')
err.err.should.be.equal(1)
err.query.should.be.equal('')
@ -1021,9 +1166,7 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(abceq,1234) should FAIL', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(abceq,1234)')
var err = whereClause.getConditionClause('(abceq,1234)')
err.err.should.be.equal(1)
err.query.should.be.equal('')
@ -1038,9 +1181,8 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(1,eq,1)(1,eq,2)~or should FAIL', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(1,eq,1)(1,eq,2)~or')
var err = whereClause.getConditionClause('(1,eq,1)(1,eq,2)~or')
err.err.should.be.equal(1)
err.query.should.be.equal('')
@ -1054,9 +1196,7 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(1,eq,1)~or~or(1,eq,2)(1,eq,2) should FAIL', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(1,eq,1)~or~or(1,eq,2)(1,eq,2)')
var err = whereClause.getConditionClause('(1,eq,1)~or~or(1,eq,2)(1,eq,2)')
err.err.should.be.equal(1)
err.query.should.be.equal('')
@ -1070,9 +1210,8 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(abc,eq,1)~or(b,eq,2) should PASS', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(abc,eq,1)~or(b,eq,2)')
var err = whereClause.getConditionClause('(abc,eq,1)~or(b,eq,2)')
err.err.should.be.equal(0)
err.query.should.be.equal('(??=?)or(??=?)')
@ -1093,9 +1232,8 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=((a,eq,1)~and(b,eq,2))~or(c,eq,3) should PASS', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('((abc,eq,1234)~and(b,eq,2))~or(cde,eq,3)')
var err = whereClause.getConditionClause('((abc,eq,1234)~and(b,eq,2))~or(cde,eq,3)')
err.err.should.be.equal(0)
err.query.should.be.equal('((??=?)and(??=?))or(??=?)')
@ -1116,9 +1254,8 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=((a,eq,1)~and(b,eq,2))~xor(c,eq,3) should PASS', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('((abc,eq,1234)~and(b,eq,2))~xor(cde,eq,3)')
var err = whereClause.getConditionClause('((abc,eq,1234)~and(b,eq,2))~xor(cde,eq,3)')
err.err.should.be.equal(0)
err.query.should.be.equal('((??=?)and(??=?))xor(??=?)')
@ -1139,9 +1276,8 @@ describe('xmysql : tests', function () {
it('where clause unit ?_where=(a,eq,1)~and((b,eq,2)~or(c,eq,3)) should PASS', function (done) {
var query = ''
var params = []
var err = whereClause.getWhereClause('(a,eq,1)~and((b,eq,2)~or(c,eq,3))')
var err = whereClause.getConditionClause('(a,eq,1)~and((b,eq,2)~or(c,eq,3))')
//console.log(query,params);
@ -1163,6 +1299,25 @@ describe('xmysql : tests', function () {
//
// it('GET http://localhost:3000/api/customers/groupby?_fields=city,country&_having=(customerNumber,lt,110) should PASS', function (done) {
//
// //post to an url with data
// agent.get('http://localhost:3000/api/customers/groupby?_fields=city,country&_having=(customerNumber,lt,110)') //enter url
// .expect(200)//200 for success 4xx for failure
// .end(function (err, res) {
// // Handle /api/v error
// if (err) {
// return done(err);
// }
//
// return done();
//
// });
// });
});

Loading…
Cancel
Save