HasMany<R extends Model> class

hasMany: related rows carry foreignKey = parent localKey.

Inheritance
Implementers

Constructors

HasMany(ModelDefinition<R> related(), {required String foreignKey, String localKey = 'id'})

Properties

foreignKey → String
final
hashCode → int
The hash code for this object.
no setterinherited
localKey → String
final
matchColumns → List<String>
The related rows' columns this relation matches them on (its foreign or owner key): added back when an eager load selects columns without them (with_('user:name') still reads users.id).
no setteroverride
name ↔ String
Name under which the relation is registered (set by the definition).
getter/setter pairinherited
parentColumns → List<String>
The parent rows' columns this relation reads (its local or foreign key): added to a parent query that selects columns without them, so the relation can still be loaded from its rows.
no setteroverride
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

correlated(ModelDefinition<Model> parent, DatabaseManager db) → ModelQuery<R>
A query on the related table correlated with the parent table, for whereHas / withCount.
override
create(Model parent, DatabaseManager db, Map<String, Object?> attributes) → Future<R>
Creates a related model with the foreign key set.
eagerLoad(List<Model> parents, DatabaseManager db, [RelationConstraint? constraint]) → Future<void>
Loads the relation for many parents in one batched query and stores the result on each parent under name.
override
existenceQuery(ModelDefinition<Model> parent, DatabaseManager db, {required String parentTable}) → ModelQuery<R>
correlated against the parent table as parentTable names it (an alias inside a self-relation subquery). The built-in relations alias their own table when it has the parent's name (categories whose children are categories); custom relations fall back to correlated.
override
loadedModels(List<Model> parents) → List<Model>
The models loaded under name on parents, flattened (for nested eager loading).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
queryFor(Model parent, DatabaseManager db) → ModelQuery<R>
Query returning the related models of one parent.
override
toString() → String
A string representation of this object.
inherited

Operators

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