In fact my condition is slightly more complex than in my example which I made easy to have the focus on the question …
The real statement looks like this:
{
complete: {
$cond: [{$and: ["$isLastReceiveTime", {$eq: [{$add: [{$max: "$mjrCounter"}, 1]}, {$size: "$mjrCounter"}]}]}, true, "$$REMOVE"]
},
completedTime: {
$cond: [{$and: ["$isLastReceiveTime", {$eq: [{$add: [{$max: "$mjrCounter"}, 1]}, {$size: "$mjrCounter"}]}]}, "$$NOW", "$$REMOVE"]
}
}
It surprises me that it is not possible to write the statement this way:
if <condition>
<action_1>
<action_2>
but instead have to write
<action_1>
if <condition>
<action_2>
if <condition>
No one would write code this way …