You can use the type
T is any type that derives
Model. It will create a reference to the primary key of the
You can point a
ForeignKey<T> to the
Model its contained in to
build self-refenencing structs.
Foreign keys on non-primary keys
ForeignKey it is not possible to reference a non-primary key.
In order to support this use case, the slightly more verbose
ForeignModelByField<T> type was created.
For the generic parameter
T, you have to use the provided
with the field access syntax.
A backref is the (virtual) reference to be able to query
"all items of a specific model with a
ForeignKey pointing to the model on
which the backref is defined on."
BackRefs are not a concept of databases, but rather a convenience
feature provided by rorm to simplify querying, there's no need to
make migrations after the field was added, as it handled internally by