RelationInfo class

Information about a relation between models.

Constructors

RelationInfo({required String name, required RelationType type, required String targetModel, required String foreignKey, List<String> references = const ['id'], String? joinTable, String? joinColumn, String? inverseJoinColumn, String? inverseRelation, bool isOwner = false})
const
RelationInfo.manyToMany({required String name, required String targetModel, required String joinTable, required String joinColumn, required String inverseJoinColumn, String? inverseRelation, bool isOwner = false})
Create a many-to-many relation.
factory
RelationInfo.manyToOne({required String name, required String targetModel, required String foreignKey, List<String> references = const ['id'], String? inverseRelation})
Create a many-to-one relation (this model belongs to target).
factory
RelationInfo.oneToMany({required String name, required String targetModel, required String foreignKey, List<String> references = const ['id'], String? inverseRelation})
Create a one-to-many relation (this model has many of target).
factory
RelationInfo.oneToOne({required String name, required String targetModel, required String foreignKey, List<String> references = const ['id'], String? inverseRelation, bool isOwner = false})
Create a one-to-one relation.
factory

Properties

foreignKey String
The foreign key field(s) on the relation side. For oneToMany: FK is on the target model (e.g., 'author_id' on Post). For manyToOne: FK is on this model (e.g., 'author_id' on Post).
final
hashCode int
The hash code for this object.
no setterinherited
inverseJoinColumn String?
For many-to-many: the column in join table referencing target model.
final
inverseRelation String?
The inverse relation name on the target model (if defined).
final
isOwner bool
Whether this is the "owner" side of the relation. The owner side holds the foreign key or is the side specified in @relation.
final
isToMany bool
Whether this is a "to-many" relation.
no setter
isToOne bool
Whether this is a "to-one" relation.
no setter
joinColumn String?
For many-to-many: the column in join table referencing this model.
final
joinTable String?
For many-to-many: the join table name.
final
name String
The relation field name (e.g., 'posts', 'author').
final
references List<String>
The field(s) that the foreign key references (usually the primary key).
final
requiresJoin bool
Whether this relation requires a JOIN to fetch.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
targetModel String
The target model name (e.g., 'Post', 'User').
final
type RelationType
The type of relation.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited