Added updateGroupOfGame(), added docc & tests
This commit is contained in:
@@ -65,6 +65,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
||||
|
||||
/// Adds a new [Game] to the database.
|
||||
/// Also adds associated players and group if they exist.
|
||||
/// If a game, player, or group already exists, it will be replaced.
|
||||
Future<void> addGame({required Game game}) async {
|
||||
await db.transaction(() async {
|
||||
await into(gameTable).insert(
|
||||
@@ -89,11 +90,18 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
||||
|
||||
if (game.group != null) {
|
||||
await db.groupDao.addGroup(group: game.group!);
|
||||
await db.groupGameDao.addGroupToGame(game.id, game.group!.id);
|
||||
await db.groupGameDao.addGroupToGame(
|
||||
gameId: game.id,
|
||||
groupId: game.group!.id,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Adds multiple [Game]s to the database in a batch operation.
|
||||
/// Also adds associated players and groups if they exist.
|
||||
/// If the [games] list is empty, the method returns immediately.
|
||||
/// If a game, player, or group already exists, it will be replaced.
|
||||
Future<void> addGames({required List<Game> games}) async {
|
||||
if (games.isEmpty) return;
|
||||
await db.transaction(() async {
|
||||
|
||||
Reference in New Issue
Block a user