mongo condition refactor

This commit is contained in:
Jan Prochazka
2024-08-19 15:31:54 +02:00
parent 8cffeaa767
commit 9fedfcbb0e
4 changed files with 119 additions and 6 deletions

View File

@@ -33,11 +33,18 @@
const ast = parseFilter(filters[uniqueName], filterBehaviour);
// console.log('AST', ast);
const cond = _.cloneDeepWith(ast, expr => {
if (expr.__placeholder__) {
if (expr.exprType == 'placeholder') {
return {
[uniqueName]: expr.__placeholder__,
exprType: 'column',
columnName: uniqueName,
};
}
// if (expr.__placeholder__) {
// return {
// [uniqueName]: expr.__placeholder__,
// };
// }
});
conditions.push(cond);
} catch (err) {
@@ -47,7 +54,8 @@
return conditions.length > 0
? {
$and: conditions,
conditionType: 'and',
conditions,
}
: undefined;
}