Skip to content

Commit afad86a

Browse files
committed
fix(types): allow $cond with $in
Fix #12028
1 parent 783ed75 commit afad86a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

test/types/expressions.test.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,15 @@ const addWithNull: Expression.Add = {
174174
'$price',
175175
{ $ifNull: ['$tax', 0] }
176176
]
177-
}
177+
};
178+
179+
const condWithIn: Expression.Cond = {
180+
$cond: {
181+
if: { $in: [] },
182+
then: '$foo',
183+
else: '$bar'
184+
}
185+
};
178186

179187
const toLong: Expression = { $toLong: '$qty' };
180188

types/expressions.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ declare module 'mongoose' {
10431043
*
10441044
* @see https://docs.mongodb.com/manual/reference/operator/aggregation/cond/#mongodb-expression-exp.-cond
10451045
*/
1046-
$cond: { if: BooleanExpression | ConditionalExpressionOperator, then: AnyExpression, else: AnyExpression } | [BooleanExpression, AnyExpression, AnyExpression];
1046+
$cond: { if: Expression, then: AnyExpression, else: AnyExpression } | [BooleanExpression, AnyExpression, AnyExpression];
10471047
}
10481048

10491049
export interface IfNull {

0 commit comments

Comments
 (0)