references function
- Object columns,
- Model target(), {
- ReferentialAction onDelete = ReferentialAction.restrict,
- bool constraint = true,
Declares a foreign key and forward navigation on the current model.
columns selects a local column or a positional Record in target primary-key
order. A named Record instead maps target field names to local columns, e.g.
(tenantId: m.tenantId, code: m.teamCode). Generation validates target names,
value types, codecs and uniqueness, and orders the mapping by the target key.
Named mappings do not provide Dart completion for target fields.
target must name a model, e.g. () => employee; generation never invokes it.
The relation's name comes from its enclosing Record field, e.g.
relations: (e) => (manager: references(e.managerId, () => employee),).
constraint false creates read-only navigation without a database foreign
key. It does not infer uniqueness or add an index.
Implementation
ReferenceDefinition references(
Object columns,
Model Function() target, {
ReferentialAction onDelete = ReferentialAction.restrict,
bool constraint = true,
}) => const ReferenceDefinition._();