tg-knex-query-resolver
Version:
TeselaGen's Knex based query resolver
26 lines (24 loc) • 647 B
JavaScript
const _ = require('lodash');
module.exports = function(filter, joinOperator){
var op = 'where';
if(joinOperator) op = joinOperator + "Where";
if(filter.chainedWith) op = filter.chainedWith + "Where";
if(_.keys(filter.args).length > 1){
// create a group if there are more than one
// where criteria to preserve order of operations
return {
op: op,
grp: [
{
op: "where",
args: filter.args
}
]
}
}else{
return {
op: op,
args: filter.args
}
}
}