I have a collection of items that can be upvoted or downvoted.
{\"_id\" : 1, \"name\": \"foo\", \"upvotes\" : 30, \"downvotes\" : 10} {\"_id\" : 2, \"name\": \"b
You want the $cond operator. http://docs.mongodb.org/manual/reference/operator/aggregation/cond/
Something like:
{"$project": { "name": "$name", "upvotes": "$upvotes", "downvotes": { $cond: [ { $eq: ["$downvotes", 0] }, 1, "$downvotes"] } } },