getSumProduct<T> method

  1. @override
Future<T> getSumProduct<T>({
  1. required Iterable<ColumnDefinition<IEntity, dynamic>> columns(
    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> getSumProduct<T>({
  required Iterable<ColumnDefinition> Function(TMeta t) columns,
  Filter Function(TMeta t)? where,
  final bool? useIsolate,
  Map<String, dynamic>? isolateArgs,
  void Function(Map<String, dynamic>? isolateArgs)? onIsolatePreMap,
}) async {
  final cols = columns(t).map((e) => e.name).join(' * ');
  List<Map> result = await rawQuery(
    where,
    'SELECT SUM ($cols) 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);
}