mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-03 00:06:56 +00:00
Feature addition : WHERE clause
version 0.0.8
This commit is contained in:
22
lib/xsql.js
22
lib/xsql.js
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user