sumField method

num sumField(
  1. String field
)

Implementation

num sumField(String field) {
  num total = 0;
  for (final document in collection.values) {
    if (document[field] is num) {
      total += document[field];
    }
  }
  return total;
}