Renamed folder to "models"

This commit is contained in:
2026-04-08 22:27:50 +02:00
parent 14d46d7e52
commit ad6d08374e
46 changed files with 795 additions and 569 deletions

View File

@@ -1,8 +1,8 @@
import 'package:drift/drift.dart';
import 'package:tallee/core/enums.dart';
import 'package:tallee/data/db/database.dart';
import 'package:tallee/data/db/tables/game_table.dart';
import 'package:tallee/data/dto/game.dart';
import 'package:tallee/core/enums.dart';
import 'package:tallee/data/models/game.dart';
part 'game_dao.g.dart';
@@ -111,14 +111,20 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
}
/// Updates the name of the game with the given [gameId] to [newName].
Future<void> updateGameName({required String gameId, required String newName}) async {
await (update(
gameTable,
)..where((g) => g.id.equals(gameId))).write(GameTableCompanion(name: Value(newName)));
Future<void> updateGameName({
required String gameId,
required String newName,
}) async {
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
GameTableCompanion(name: Value(newName)),
);
}
/// Updates the ruleset of the game with the given [gameId].
Future<void> updateGameRuleset({required String gameId, required Ruleset newRuleset}) async {
Future<void> updateGameRuleset({
required String gameId,
required Ruleset newRuleset,
}) async {
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
GameTableCompanion(ruleset: Value(newRuleset.name)),
);
@@ -135,24 +141,31 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
}
/// Updates the color of the game with the given [gameId].
Future<void> updateGameColor({required String gameId, required GameColor newColor}) async {
await (update(
gameTable,
)..where((g) => g.id.equals(gameId))).write(GameTableCompanion(color: Value(newColor.name)));
Future<void> updateGameColor({
required String gameId,
required GameColor newColor,
}) async {
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
GameTableCompanion(color: Value(newColor.name)),
);
}
/// Updates the icon of the game with the given [gameId].
Future<void> updateGameIcon({required String gameId, required String newIcon}) async {
await (update(
gameTable,
)..where((g) => g.id.equals(gameId))).write(GameTableCompanion(icon: Value(newIcon)));
Future<void> updateGameIcon({
required String gameId,
required String newIcon,
}) async {
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
GameTableCompanion(icon: Value(newIcon)),
);
}
/// Retrieves the total count 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();
final count =
await (selectOnly(gameTable)..addColumns([gameTable.id.count()]))
.map((row) => row.read(gameTable.id.count()))
.getSingle();
return count ?? 0;
}