Skip to content

Commit

Permalink
fix(types): allow $cond with $in
Browse files Browse the repository at this point in the history
Fix #12028
  • Loading branch information
vkarpov15 committed Jul 5, 2022
1 parent 783ed75 commit afad86a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion test/types/expressions.test.ts
Expand Up @@ -174,7 +174,15 @@ const addWithNull: Expression.Add = {
'$price',
{ $ifNull: ['$tax', 0] }
]
}
};

const condWithIn: Expression.Cond = {
$cond: {
if: { $in: [] },
then: '$foo',
else: '$bar'
}
};

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

Expand Down
2 changes: 1 addition & 1 deletion types/expressions.d.ts
Expand Up @@ -1043,7 +1043,7 @@ declare module 'mongoose' {
*
* @see https://docs.mongodb.com/manual/reference/operator/aggregation/cond/#mongodb-expression-exp.-cond
*/
$cond: { if: BooleanExpression | ConditionalExpressionOperator, then: AnyExpression, else: AnyExpression } | [BooleanExpression, AnyExpression, AnyExpression];
$cond: { if: Expression, then: AnyExpression, else: AnyExpression } | [BooleanExpression, AnyExpression, AnyExpression];
}

export interface IfNull {
Expand Down

0 comments on commit afad86a

Please sign in to comment.