EntityRelation.oneToOne constructor
Constructs an instance of one-to-one relation.
Example
import 'package:kind/kind.dart';
class Company extends Entity {
static final EntityKind<Company> kind = EntityKind<Company>(
name: 'Company',
define: (c) {
// ...
c.optional<Employee>(
id: 2,
name: 'bestEmployee',
itemsKind: Employee.kind,
field: (company) => company.bestEmployee,
relation: EntityRelation.oneToOne('best_employee_id', 'id'),
);
// ...
},
);
late final Field<Employee?> bestEmployee = Field<Employee?>();
}
Implementation
factory EntityRelation.oneToOne(
String localPropName, String foreignPropName) {
return EntityRelation(
localPropNames: [localPropName],
foreignPropNames: [foreignPropName],
);
}