fetchRelated<P extends DatumEntityInterface, R extends DatumEntityInterface> method
Future<List<R> >
fetchRelated<P extends DatumEntityInterface, R extends DatumEntityInterface>(
- P parent,
- String relationName, {
- DataSource source = DataSource.local,
Fetches related entities with proper type checking for RelationalDatumEntity
Implementation
Future<List<R>> fetchRelated<P extends DatumEntityInterface, R extends DatumEntityInterface>(
P parent,
String relationName, {
DataSource source = DataSource.local,
}) async {
// Type-safe check using sealed class pattern matching
switch (parent) {
case RelationalDatumEntity():
return Datum.managerByType(parent.runtimeType).fetchRelated<R>(parent, relationName, source: source);
case _:
throw ArgumentError(
'Entity of type ${parent.runtimeType} is not relational and cannot have relations. '
'To use relations, extend RelationalDatumEntity instead of DatumEntity or use RelationalDatumEntityMixin to use `with` block.',
);
}
}