Added Database, Tables & DAOs
This commit is contained in:
16
lib/data/db/tables/game_session_table.dart
Normal file
16
lib/data/db/tables/game_session_table.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
class GameSessionTable extends Table {
|
||||
TextColumn get id => text()();
|
||||
DateTimeColumn get createdAt => dateTime()();
|
||||
TextColumn get gameTitle => text()();
|
||||
IntColumn get pointLimit => integer()();
|
||||
IntColumn get caboPenalty => integer()();
|
||||
BoolColumn get isPointsLimitEnabled => boolean()();
|
||||
BoolColumn get isGameFinished => boolean()();
|
||||
TextColumn get winner => text().nullable()();
|
||||
IntColumn get roundNumber => integer()();
|
||||
|
||||
@override
|
||||
Set<Column<Object>> get primaryKey => {id};
|
||||
}
|
||||
13
lib/data/db/tables/player_scores.dart
Normal file
13
lib/data/db/tables/player_scores.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:cabo_counter/data/db/tables/game_session_table.dart';
|
||||
import 'package:cabo_counter/data/db/tables/players_table.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
class PlayerScoresTable extends Table {
|
||||
TextColumn get roundId =>
|
||||
text().references(GameSessionTable, #id, onDelete: KeyAction.cascade)();
|
||||
TextColumn get playerName => text().references(PlayersTable, #name)();
|
||||
IntColumn get totalScore => integer()();
|
||||
|
||||
@override
|
||||
Set<Column<Object>> get primaryKey => {roundId, playerName};
|
||||
}
|
||||
8
lib/data/db/tables/players_table.dart
Normal file
8
lib/data/db/tables/players_table.dart
Normal file
@@ -0,0 +1,8 @@
|
||||
import 'package:cabo_counter/data/db/tables/game_session_table.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
class PlayersTable extends Table {
|
||||
TextColumn get id =>
|
||||
text().references(GameSessionTable, #id, onDelete: KeyAction.cascade)();
|
||||
TextColumn get name => text()();
|
||||
}
|
||||
13
lib/data/db/tables/round_scores_table.dart
Normal file
13
lib/data/db/tables/round_scores_table.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:cabo_counter/data/db/tables/rounds_table.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
class RoundScoresTable extends Table {
|
||||
TextColumn get roundId =>
|
||||
text().references(RoundsTable, #id, onDelete: KeyAction.cascade)();
|
||||
TextColumn get playerName => text()();
|
||||
IntColumn get score => integer()();
|
||||
IntColumn get scoreUpdate => integer()();
|
||||
|
||||
@override
|
||||
Set<Column<Object>> get primaryKey => {roundId, playerName};
|
||||
}
|
||||
13
lib/data/db/tables/rounds_table.dart
Normal file
13
lib/data/db/tables/rounds_table.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:cabo_counter/data/db/tables/game_session_table.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
class RoundsTable extends Table {
|
||||
TextColumn get id => text()();
|
||||
TextColumn get gameId =>
|
||||
text().references(GameSessionTable, #id, onDelete: KeyAction.cascade)();
|
||||
IntColumn get roundNumber => integer()();
|
||||
TextColumn get kamikazePlayer => text().nullable()();
|
||||
|
||||
@override
|
||||
Set<Column<Object>> get primaryKey => {id};
|
||||
}
|
||||
Reference in New Issue
Block a user