avg method
Implementation
@override
Future<double?> avg(
String table,
String column, {
String? where,
List<Object?>? whereArgs,
}) async {
try {
if (database == null) {
throw const DatabaseBridgeException(
error: 'Database is not initialized',
);
}
final result = await database!.rawQuery(
'SELECT AVG($column) as avg FROM $table${where != null ? ' WHERE $where' : ''}',
whereArgs,
);
return result.isNotEmpty ? result.first['avg'] as double? : null;
} catch (e) {
throw DatabaseBridgeException(error: e);
}
}