Added counting methods + testing those

This commit is contained in:
2025-11-12 20:09:17 +01:00
parent 39b2068121
commit 9229f1f0a5
3 changed files with 45 additions and 0 deletions

View File

@@ -61,4 +61,13 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
PlayerTableCompanion(name: Value(newName)),
);
}
/// Retrieves the total count of players in the database.
Future<int> getPlayerCount() async {
final count =
await (selectOnly(playerTable)..addColumns([playerTable.id.count()]))
.map((row) => row.read(playerTable.id.count()))
.getSingle();
return count ?? 0;
}
}