ForeignKey class
For define foreign key in entities, you have to use this class. Foreign keys allows you to specify constraints across entities such that SQLite will ensure that the relationship is valid when you modify the database. A foreign key constraint can be deferred until the transaction is complete. This is useful if you are doing bulk inserts into the database in a single transaction. By default, foreign key constraints are immediate but you can change this value by setting deferred to true.
Constructors
-
ForeignKey({required Object entity, required List<
String> parentColumns, required List<String> childColumns, ForeignKeyAction onDelete = ForeignKeyAction.NO_ACTION, ForeignKeyAction onUpdate = ForeignKeyAction.NO_ACTION, bool deferred = false}) -
const
Properties
-
childColumns
→ List<
String> -
The list of column names in the current Entity.
Number of columns must match the number of columns
specified in parentColumns.
final
- deferred → bool
-
A foreign key constraint can be deferred until the transaction is
complete. This is useful if you are doing bulk inserts into the database
in a single transaction. By default, foreign key constraints are
immediate but you can change it by setting this field to true.
final
- entity → Object
-
The parent Entity to reference. It must be a class
annotated with Entity and referenced in the same database.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- onDelete → ForeignKeyAction
-
Action to take when the parent Entity is deleted from the database.
Default value of onDelete is ForeignKeyAction.NO_ACTION
final
- onUpdate → ForeignKeyAction
-
Action to take when the parent Entity is updated in the database.
Default value of onUpdate is ForeignKeyAction.NO_ACTION
final
-
parentColumns
→ List<
String> -
The list of column names in the parent Entity.
Number of columns must match the number of columns
specified in childColumns.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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