I am trying to count how much messages exists on my db collection and return a custom key: value, If this greater than 1 countable it’s return true(1) else return false(0).
I tried the shell below, but not working yet… I think I am near to correct aggregation, but I am don’t know.
because it is on the right side of a colon. It is a value. A value has to be in quote if it is not a symbol or a number. You quoted $amount correctly.
But putting $count would not do what you want to do. This is not how you count documents. You may use a $group stage with the $sum accumulator or a $count stage.
Another thing that would not work is using $amount in the same $project stage that creates it. A field created by $project or $set is only available in the next stage.