Relations class

Clean, static helper methods for defining relations

Constructors

Relations()

Properties

hashCode int
The hash code for this object.
no setterinherited
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

Static Methods

belongsTo<T extends Model<T>>(String name, T relatedFactory(), {String? foreignKey, String? ownerKey}) RelationDefinition<Model>
Define a belongsTo relationship Example: Relations.belongsTo('category', () => Category())
belongsToMany<T extends Model<T>>(String name, T relatedFactory(), {required String pivotTable, required String relatedPivotKey, required String foreignPivotKey, String? foreignKey, String? ownerKey}) RelationDefinition<Model>
Define a belongsToMany (many-to-many) relationship Example: Relations.belongsToMany('tags', () => Tag(), ...)
hasMany<T extends Model<T>>(String name, T relatedFactory(), {String? foreignKey, String? ownerKey}) RelationDefinition<Model>
Define a hasMany relationship Example: Relations.hasMany('comments', () => Comment())
hasOne<T extends Model<T>>(String name, T relatedFactory(), {String? foreignKey, String? ownerKey}) RelationDefinition<Model>
Define a hasOne relationship Example: Relations.hasOne('profile', () => Profile())