Skip to content

Commit

Permalink
fix: parses incoming numbers through query string for use in where cl…
Browse files Browse the repository at this point in the history
…auses
  • Loading branch information
jmikrut committed Jun 22, 2021
1 parent 67c1e28 commit 4933b34
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/mongoose/buildQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,22 @@ class ParamParser {
}
}
let formattedValue = val;
if (schemaObject && schemaObject.type === Boolean && typeof val === 'string') {

const schemaObjectType = schemaObject?.localized ? schemaObject?.type[this.locale].type : schemaObject?.type;

if (schemaObject && schemaObjectType === Boolean && typeof val === 'string') {
if (val.toLowerCase() === 'true') formattedValue = true;
if (val.toLowerCase() === 'false') formattedValue = false;
}

if (schemaObject && schemaObjectType === Number && typeof val === 'string') {
formattedValue = Number(val);
}

if (schemaObject && schemaObject.ref && val === 'null') {
formattedValue = null;
}

if (operator && validOperators.includes(operator)) {
switch (operator) {
case 'greater_than_equal':
Expand Down

0 comments on commit 4933b34

Please sign in to comment.