match method
List<KhademModel>
match(
- List<
KhademModel> models, - List<
Related> results, - String relation
override
Match the eagerly loaded results to their parents.
Implementation
@override
List<KhademModel> match(
List<KhademModel> models,
List<Related> results,
String relation,
) {
final dictionary = <dynamic, Related>{};
for (final result in results) {
final key = result.getAttribute('khadem_through_key');
if (key != null) {
dictionary[key] = result;
}
}
for (final model in models) {
final key = model.getAttribute(localKey);
if (dictionary.containsKey(key)) {
model.setRelation(relation, dictionary[key]);
}
}
return models;
}