Skip to content

Commit 933c6b0

Browse files
authored
Merge pull request #15425 from redlizard/expr-boolean-literal
fix: Support $expr clauses with a boolean literal as an expression
2 parents c054618 + 52d3655 commit 933c6b0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/helpers/query/cast$expr.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ const dateOperators = new Set([
6969
const expressionOperator = new Set(['$not']);
7070

7171
module.exports = function cast$expr(val, schema, strictQuery) {
72+
if (typeof val === 'boolean') {
73+
return val;
74+
}
7275
if (typeof val !== 'object' || val === null) {
73-
throw new Error('`$expr` must be an object');
76+
throw new Error('`$expr` must be an object or boolean literal');
7477
}
7578

7679
return _castExpression(val, schema, strictQuery);

0 commit comments

Comments
 (0)