touchOwners method
Touches the owning relations of the model.
Implementation
Future<void> touchOwners() async {
if (!_shouldTouchOwners(requireDirty: false)) {
return;
}
if (_touchingOwners[this] == true) {
return;
}
_touchingOwners[this] = true;
try {
final def = expectDefinition();
final resolver = _resolveResolverFor(def);
final context = _requireQueryContext(resolver);
for (final relationName in touches) {
final relationDef = def.relations.cast<RelationDefinition?>().firstWhere(
(r) => r?.name == relationName,
orElse: () => null,
);
if (relationDef == null) {
continue;
}
await _touchRelation(def, relationDef, resolver, context);
if (!_isTracked) {
continue;
}
final loaded = _asRelations.getRelation<dynamic>(relationName);
if (loaded is Model) {
await loaded.touchOwners();
} else if (loaded is Iterable) {
for (final item in loaded) {
if (item is Model) {
await item.touchOwners();
}
}
}
}
} finally {
_touchingOwners[this] = false;
}
}