// Get sum of a certain field across all the documents in a collection
db.getCollection('simple-arb').aggregate([
{
$match: {
closed: {
$eq: true
}
}
}, {
$group: {
_id: null,
total: {
$sum: "$actualProfit"
}
}
}
])