@synatic/noql
Advanced tools
Comparing version 4.1.11 to 4.1.12
@@ -423,2 +423,12 @@ const {snakeCase} = require('lodash'); | ||
const field = Object.keys(d)[0]; | ||
if (field === '$expr') { | ||
const res = mapMatchesToExpressionFormat(d, sourceName); | ||
findLetValuesAndModifyExpression( | ||
res, | ||
sourceName, | ||
lookup.$lookup.let | ||
); | ||
return res; | ||
} | ||
const letVar = snakeCase(field); | ||
@@ -662,3 +672,3 @@ const explicitKey = `$${letVar}`; | ||
* | ||
* @param expression | ||
* @param {Record<string,unknown>} expression | ||
* @param {string} mustContain | ||
@@ -709,2 +719,25 @@ * @param {string} mustNotContain | ||
* | ||
* @param {Record<string,unknown>} expression | ||
* @param {string} sourceName | ||
* @param {Record<string,unknown>} letObj | ||
*/ | ||
function findLetValuesAndModifyExpression(expression, sourceName, letObj) { | ||
const key = Object.keys(expression)[0]; | ||
const values = Object.values(expression)[0]; | ||
if ($check.array(values)) { | ||
values.forEach((value) => { | ||
if ($check.object(value)) { | ||
findLetValuesAndModifyExpression(value, sourceName, letObj); | ||
} | ||
}); | ||
return; | ||
} | ||
if ($check.string(values) && values.startsWith(`$${sourceName}`)) { | ||
const letVar = snakeCase(values); | ||
letObj[letVar] = values; | ||
expression[key] = letVar; | ||
} | ||
} | ||
/** | ||
* | ||
* @param match | ||
@@ -711,0 +744,0 @@ * @param {string} sourceName |
{ | ||
"name": "@synatic/noql", | ||
"version": "4.1.11", | ||
"version": "4.1.12", | ||
"description": "Convert SQL statements to mongo queries or aggregates", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
362568
9407