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.
|
/// Adds a new [Game] to the database.
|
||||||
/// Also adds associated players and group if they exist.
|
/// 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 {
|
Future<void> addGame({required Game game}) async {
|
||||||
await db.transaction(() async {
|
await db.transaction(() async {
|
||||||
await into(gameTable).insert(
|
await into(gameTable).insert(
|
||||||
|
|||||||
@@ -11,12 +11,14 @@ class GroupGameDao extends DatabaseAccessor<AppDatabase>
|
|||||||
GroupGameDao(super.db);
|
GroupGameDao(super.db);
|
||||||
|
|
||||||
/// Associates a group with a game by inserting a record into the
|
/// Associates a group with a game by inserting a record into the
|
||||||
/// [GroupGameTable]. If there is already group associated to the game,
|
/// [GroupGameTable].
|
||||||
/// it will be replaced.
|
|
||||||
Future<void> addGroupToGame({
|
Future<void> addGroupToGame({
|
||||||
required String gameId,
|
required String gameId,
|
||||||
required String groupId,
|
required String groupId,
|
||||||
}) async {
|
}) async {
|
||||||
|
if (await gameHasGroup(gameId: gameId)) {
|
||||||
|
throw Exception('Game already has a group');
|
||||||
|
}
|
||||||
await into(groupGameTable).insert(
|
await into(groupGameTable).insert(
|
||||||
GroupGameTableCompanion.insert(groupId: groupId, gameId: gameId),
|
GroupGameTableCompanion.insert(groupId: groupId, gameId: gameId),
|
||||||
mode: InsertMode.insertOrReplace,
|
mode: InsertMode.insertOrReplace,
|
||||||
|
|||||||
Reference in New Issue
Block a user