loadSum method
Lazily loads the sum of a column in a relation.
Stores the sum result as an attribute with the suffix _sum_{column}.
Example:
await post.loadSum('comments', 'likes');
final totalLikes = post.getAttribute<num>('comments_sum_likes') ?? 0;
Implementation
Future<TModel> loadSum(
String relation,
String column, {
String? alias,
PredicateCallback<OrmEntity>? constraint,
}) async {
return _loadAggregate(
RelationAggregateType.sum,
relation,
column,
alias: alias,
constraint: constraint,
);
}