hasOne<R extends Model> method

HasOne<R> hasOne<R extends Model>(
  1. R creator(
    1. Map<String, dynamic>
    ), {
  2. String? foreignKey,
  3. String? localKey,
})
inherited

Defines a 1:1 relationship where the Foreign Key resides on the related model R.

Example: User has one Phone. (Phone table has user_id).

Implementation

HasOne<R> hasOne<R extends Model>(
  R Function(Map<String, dynamic>) creator, {
  String? foreignKey,
  String? localKey,
}) {
  return HasOne<R>(
    _asModel,
    creator,
    foreignKey ?? Utils.foreignKey(table),
    localKey ?? primaryKey,
  );
}