Implemented retrieving game and group count from the db

This commit is contained in:
2025-11-11 21:03:10 +01:00
parent 4f8ba002d3
commit dd754eb569
3 changed files with 65 additions and 13 deletions

View File

@@ -22,4 +22,13 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
final result = await query.getSingle();
return Game(id: result.id, name: result.name);
}
/// Retrieves the number of games in the database.
Future<int> getGameCount() async {
final count =
await (selectOnly(gameTable)..addColumns([gameTable.id.count()]))
.map((row) => row.read(gameTable.id.count()))
.getSingle();
return count ?? 0;
}
}

View File

@@ -56,4 +56,13 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
);
return rowsAffected > 0;
}
/// Retrieves the number of groups in the database.
Future<int> getGroupCount() async {
final count =
await (selectOnly(groupTable)..addColumns([groupTable.id.count()]))
.map((row) => row.read(groupTable.id.count()))
.getSingle();
return count ?? 0;
}
}