aggregateCount method

Map<dynamic, int> aggregateCount(
  1. String fieldName
)

Implementation

Map<dynamic, int> aggregateCount(String fieldName) {
  final Map<dynamic, int> counts = {};
  for (final document in collection.values) {
    final fieldValue = document[fieldName];
    if (!counts.containsKey(fieldValue)) {
      counts[fieldValue] = 0;
    }
    counts[fieldValue] = counts[fieldValue]! + 1;
  }
  return counts;
}