EntityRelation.oneToMany constructor

EntityRelation.oneToMany(
  1. String localPropName,
  2. String foreignPropName
)

Constructs an instance of one-to-many relation.

Example

import 'package:kind/kind.dart';

class Company extends Entity {
  static final EntityKind<Company> kind = EntityKind<Company>(
    name: 'Company',
    define: (c) {
      // ...
      c.requiredSet<Employee>(
        id: 2,
        name: employees',
        itemsKind: Employee.kind,
        field: (company) => company.employees,
        relation: EntityRelation.oneToOne('id', 'company_id'),
      );
      // ...
    },
  );

  late final Field<Employee?> bestEmployee = Field<Employee?>();
}

Implementation

factory EntityRelation.oneToMany(
    String localPropName, String foreignPropName) {
  return EntityRelation(
    localPropNames: [localPropName],
    foreignPropNames: [foreignPropName],
  );
}