getSum<T> method

  1. @override
Future<T> getSum<T>({
  1. required ColumnDefinition<IEntity, dynamic> column(
    1. TMeta t
    ),
  2. Filter where(
    1. TMeta t
    )?,
  3. bool? useIsolate,
  4. Map<String, dynamic>? isolateArgs,
  5. void onIsolatePreMap(
    1. Map<String, dynamic>? isolateArgs
    )?,
})
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);
}