I have a document related to the role or designations of employees. This is the document structure.
{ \"_id\" : ObjectId(\"5660c2a5b6fcba2d47baa2d9\"),
You have to use $group instead:
$group
db.employee_role.aggregate( { $group: { _id: "$role_title", total: { $sum: { $size:"$employees" } } } } )
You group by role_title and then, you add the number of employees.
role_title