TargetIdProperty constructor

const TargetIdProperty(
  1. String name
)

For a ToOne, changes the name of its associated target ID (or "relation") property.

@Entity()
class Order {
    // Change from default "customerId" to "customerRef"
    @TargetIdProperty("customerRef")
    final customer = ToOne<Customer>();
}

A target ID property is implicitly created (so without defining it in the @Entity class) for each ToOne and stores the ID of the referenced target object. By default, it's named like the ToOne field plus the suffix Id (for example customerId).

See the relations documentation for details.

Implementation

const TargetIdProperty(this.name);