index method
Implementation
void index(String fieldName) {
final Map<dynamic, List<String>> index = {};
for (final id in collection.keys) {
final document = collection[id];
final fieldValue = document[fieldName];
if (!index.containsKey(fieldValue)) {
index[fieldValue] = [];
}
index[fieldValue]?.add(id);
}
collection['$fieldName-index'] = index;
}