MongoDB Summation vs Count Query

In MongoDB, when you want to summate a key, you need to distinguish from summating and counting. The below examples try to illustrate the differences:

Summate occurences

db.collection.aggregate(  
   [
     {$match: { key:value } },
     {
       $group:
         {
           _id: null,
           count: { $sum: 1}
         }
     }
   ]
)

Summate integers:

db.collection.aggregate(  
   [
     {$match: { key:value } },
     {
       $group:
         {
           _id: null,
           count: { $sum: "$summableKey"}
         }
     }
   ]
)