max method

  1. @override
Future<Object?> max(
  1. String table,
  2. String column, {
  3. String? where,
  4. List<Object?>? whereArgs,
})
override

Implementation

@override
Future<Object?> max(
  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 MAX($column) as max FROM $table${where != null ? ' WHERE $where' : ''}',
      whereArgs,
    );
    return result.isNotEmpty ? result.first['max'] : null;
  } catch (e) {
    throw DatabaseBridgeException(error: e);
  }
}