Compare commits
3 Commits
dc0e536221
...
d2d6852f31
| Author | SHA1 | Date | |
|---|---|---|---|
| d2d6852f31 | |||
| 126dc7ed97 | |||
| 40a3c1b82e |
@@ -65,7 +65,6 @@ 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(
|
||||
|
||||
@@ -11,12 +11,14 @@ class GroupGameDao extends DatabaseAccessor<AppDatabase>
|
||||
GroupGameDao(super.db);
|
||||
|
||||
/// Associates a group with a game by inserting a record into the
|
||||
/// [GroupGameTable]. If there is already group associated to the game,
|
||||
/// it will be replaced.
|
||||
/// [GroupGameTable].
|
||||
Future<void> addGroupToGame({
|
||||
required String gameId,
|
||||
required String groupId,
|
||||
}) async {
|
||||
if (await gameHasGroup(gameId: gameId)) {
|
||||
throw Exception('Game already has a group');
|
||||
}
|
||||
await into(groupGameTable).insert(
|
||||
GroupGameTableCompanion.insert(groupId: groupId, gameId: gameId),
|
||||
mode: InsertMode.insertOrReplace,
|
||||
|
||||
Reference in New Issue
Block a user