referencedBy function

ReferenceDefinition referencedBy(
  1. Model target(), {
  2. Record? on,
})

Declares reverse navigation on the current model, without another foreign key.

target must name a model, e.g. () => employee, with a forward references declaration pointing to the current model. Generation requires one matching reference; no match or ambiguity is an error, never a naming heuristic.

When several references exist, on maps target foreign-key field names to local columns, e.g. referencedBy(() => post, on: (authorId: u.id)). This also supports composite keys. Mapping names are checked by generation; local columns retain native Dart types and completion. A reverse of a read-only forward reference is also read-only. Callbacks are never invoked.

Implementation

ReferenceDefinition referencedBy(Model Function() target, {Record? on}) =>
    const ReferenceDefinition._();