count method
Count records
Implementation
Future<int> count() async {
try {
final db = await database;
final query = "SELECT COUNT(*) as count FROM $table";
if (_whereConditions.isNotEmpty) {
final whereClause = _whereConditions.join(" ");
final fullQuery = "$query WHERE $whereClause";
final result = await db.rawQuery(fullQuery, _bindings);
return result.first['count'] as int;
}
final result = await db.rawQuery(query);
return result.first['count'] as int;
} catch (e) {
throw DatabaseException('Failed to count records: $e');
}
}