Add some features to advanced queries
This commit is contained in:
parent
84881a00e9
commit
a34d277ef8
|
@ -104,6 +104,12 @@ MySQL.prototype.toDatabase = function (prop, val) {
|
|||
return this.toDatabase(prop, val[0]) +
|
||||
' AND ' +
|
||||
this.toDatabase(prop, val[1]);
|
||||
} else if (operator == 'inq' || operator == 'nin') {
|
||||
if (!(val.propertyIsEnumerable('length')) && typeof val === 'object' && typeof val.length === 'number') { //if value is array
|
||||
return val.join(',');
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (prop.type.name === 'Number') return val;
|
||||
|
@ -219,8 +225,17 @@ MySQL.prototype.all = function all(model, filter, callback) {
|
|||
case 'between':
|
||||
sqlCond += ' BETWEEN ';
|
||||
break;
|
||||
case 'inq':
|
||||
sqlCond += ' IN ';
|
||||
break;
|
||||
case 'nin':
|
||||
sqlCond += ' NOT IN ';
|
||||
break;
|
||||
case 'neq':
|
||||
sqlCond + ' != ';
|
||||
break;
|
||||
}
|
||||
sqlCond += val;
|
||||
sqlCond += (condType == 'inq' || condType == 'nin') ? '(' + val + ')' : val;
|
||||
cs.push(sqlCond);
|
||||
} else {
|
||||
cs.push(keyEscaped + ' = ' + val);
|
||||
|
|
Loading…
Reference in New Issue