Oh I get the $unwind: '$total': it is because the field count that gets created has an array as value with a single integer element inside of it. Unwind creates a document foreach element in that array, but because there is only one it effectively pulls the single integer out of the array and uses that. Without this unwind the $divide errors about one value being an array.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Oh I get the
$unwind: '$total'
: it is because the field count that gets created has an array as value with a single integer element inside of it. Unwind creates a document foreach element in that array, but because there is only one it effectively pulls the single integer out of the array and uses that. Without this unwind the $divide errors about one value being an array.