getSum<T> method
Future<T>
getSum<T>({
- required ColumnDefinition<
IEntity, dynamic> column(- TMeta t
- Filter where(
- TMeta t
- bool? useIsolate,
- Map<
String, dynamic> ? isolateArgs, - void onIsolatePreMap()?,
inherited
Implementation
@override
Future<T> getSum<T>({
required ColumnDefinition Function(TMeta t) column,
Filter Function(TMeta t)? where,
final bool? useIsolate,
Map<String, dynamic>? isolateArgs,
void Function(Map<String, dynamic>? isolateArgs)? onIsolatePreMap,
}) async {
List<Map> result = await rawQuery(
where,
'SELECT SUM (${column(t).name}) FROM ${t.tableName}',
useIsolate: useIsolate,
isolateArgs: isolateArgs,
onIsolatePreMap: onIsolatePreMap,
);
if (result.isNotEmpty) {
final firstRow = result.first;
if (firstRow.isNotEmpty && firstRow.values.first != null) {
return asCast<T>(firstRow.values.first);
}
}
return asCast<T>(0);
}