HasOne<R extends Model> class
final
hasOne: like HasMany but a single row.
Properties
- foreignKey → String
-
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- localKey → String
-
finalinherited
-
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 readsusers.id).no setterinherited - 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 setterinherited
-
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
A query on the related table correlated with the parent table, for
whereHas/withCount.inherited -
create(
Model parent, DatabaseManager db, Map< String, Object?> attributes) → Future<R> -
Creates a related model with the foreign key set.
inherited
-
eagerLoad(
List< Model> parents, DatabaseManager db, [RelationConstraint? constraint]) → Future<void> -
Loads the relation for many
parentsin 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
parentTablenames it (an alias inside a self-relation subquery). The built-in relations alias their own table when it has the parent's name (categorieswhosechildrenarecategories); custom relations fall back to correlated.inherited -
latestOfMany(
[String column = 'id']) → HasOne< R> -
latestOfMany(): the row with the largestcolumnof a has-many. -
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
-
ofMany(
String column, String aggregate) → HasOne< R> -
ofMany('score', 'max'). Eager loading reads one row per parent, with a correlated subquery. Rows with the samecolumngo by the primary key. -
oldestOfMany(
[String column = 'id']) → HasOne< R> -
oldestOfMany(): the row with the smallestcolumn. -
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