ManyToOne class
ManyToOne relationship annotation
Defines a many-to-one relationship between entities. Use this on the "many" side - this entity will have the foreign key column.
Example:
// In PostEntity (the "many" side - has FK column)
@ManyToOne(
targetEntity: UserEntity,
foreignKey: 'author_id', // FK column name in this table
referencedColumn: 'id', // Referenced column in UserEntity
)
UserEntity? author;
Constructors
- ManyToOne({required Type targetEntity, String? foreignKey, String referencedColumn = 'id', bool cascadeDelete = false, bool lazyLoad = true, bool eagerLoad = false, bool nullable = true, RelationAction onDelete = RelationAction.noAction, RelationAction onUpdate = RelationAction.noAction})
-
const
Properties
- cascadeDelete → bool
-
Whether to cascade delete operations
final
- eagerLoad → bool
-
Whether to eager load the relationship
final
- foreignKey → String?
-
Foreign key column name in this entity's table
If not provided, defaults to {targetEntity}_id in snake_case
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- lazyLoad → bool
-
Whether to lazy load the relationship
final
- nullable → bool
-
Whether this relationship is nullable
final
- onDelete → RelationAction
-
Action to take on delete of referenced entity
final
- onUpdate → RelationAction
-
Action to take on update of referenced entity
final
- referencedColumn → String
-
Referenced column in the target entity (usually 'id')
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- targetEntity → Type
-
The target entity type for this relationship
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