groupBy method
Implementation
Map<dynamic, List<Map<String, dynamic>>> groupBy(String fieldName) {
final Map<dynamic, List<Map<String, dynamic>>> groups = {};
for (final document in collection.values) {
final fieldValue = document[fieldName];
if (!groups.containsKey(fieldValue)) {
groups[fieldValue] = [];
}
groups[fieldValue]?.add(document);
}
return groups;
}