loadMissing method

Future<ModelCollection<T>> loadMissing(
  1. List<String> relations
)

Loads relations only on models that do not have them yet.

Implementation

Future<ModelCollection<T>> loadMissing(List<String> relations) async {
  for (final relation in relations) {
    final pending = where(
      (model) => !model.relationLoaded(relation.split('.').first),
    ).toList();
    if (pending.isNotEmpty) {
      await pending.first.modelDefinition.eagerLoad(pending, [
        relation,
      ], db: pending.first.database);
    }
  }
  return this;
}