Skip to content

Commit

Permalink
test(types): test $let as a possible expression to $addFields
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanHafez committed Jul 11, 2022
1 parent db1ba6e commit 38c53b8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/types/PipelineStage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,26 @@ const stages3: PipelineStage[] = [
}
}
];

const stages4: PipelineStage[] = [
{
$addFields: {
usersCount: {
$let: {
vars: {
users: { $push: '$user' }
},
in: {
$reduce: {
input: '$users',
initialValue: 0,
in: {
$cond: { if: { $isArray: '$$this' }, then: { $size: '$$this' }, else: '$$this' }
}
}
}
}
}
}
}
];

0 comments on commit 38c53b8

Please sign in to comment.