loadBelongsTo method

Future<R?> loadBelongsTo(
  1. T owner
)

Load the related entity for a belongsTo relation. owner is the owner entity; foreignKey (set in belongsTo) is the field on owner holding the related id.

Implementation

Future<R?> loadBelongsTo(T owner) {
  final fkValue = _getFieldValue(ownerCollection, owner, foreignKey);
  if (fkValue == null) return Future.value(null);
  final id = fkValue is int ? fkValue : int.tryParse(fkValue.toString());
  if (id == null) return Future.value(null);
  return relatedCollection.getById(id);
}