loadAvg method
Lazily loads the average of a column in a relation.
Stores the average result as an attribute with the suffix _avg_{column}.
Example:
await post.loadAvg('comments', 'rating');
final avgRating = post.getAttribute<num>('comments_avg_rating') ?? 0;
Implementation
Future<TModel> loadAvg(
String relation,
String column, {
String? alias,
PredicateCallback<OrmEntity>? constraint,
}) async {
return _loadAggregate(
RelationAggregateType.avg,
relation,
column,
alias: alias,
constraint: constraint,
);
}