Feature addition : WHERE clause

version 0.0.8
This commit is contained in:
oof1lab
2017-11-02 20:13:42 +00:00
parent ee3d65e17e
commit 7df4c93a30
7 changed files with 286 additions and 102 deletions

View File

@@ -2,8 +2,10 @@
const mysql = require('mysql');
const dataHelp = require('./util/data.helper.js');
const whereHelp = require('./util/whereClause.helper.js');
const assert = require('assert')
//define class
class Xsql {
@@ -171,6 +173,24 @@ class Xsql {
}
getWhereClause(queryparams, tableName, queryParamsObj, appendToWhere) {
let addWhereStr = ''
if (queryparams && queryparams._where) {
let whereClauseObj = whereHelp.getWhereClause(queryparams._where)
if (whereClauseObj.err === 0) {
queryParamsObj.query = queryParamsObj.query + appendToWhere + whereClauseObj.query;
queryParamsObj.params = queryParamsObj.params.concat(whereClauseObj.params)
}
//console.log('> > > after where clause filling up:', queryParamsObj.query, queryParamsObj.params);
}
}
getOrderByClause(queryparams, tableName) {
//defaults
@@ -217,7 +237,7 @@ class Xsql {
// get column name in _fields and mark column name which start with '-'
for (let i = 0; i < _fieldsInQuery.length; ++i) {
if (_fieldsInQuery[i][0] == '-') {
if (_fieldsInQuery[i][0] === '-') {
removeFieldsObj[_fieldsInQuery[i].substring(1, _fieldsInQuery[i].length)] = 1;
} else {
cols.push(_fieldsInQuery[i])