Added Database, Tables & DAOs
This commit is contained in:
10
lib/data/db/dao/game_session_dao.dart
Normal file
10
lib/data/db/dao/game_session_dao.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'package:cabo_counter/data/db/database.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
part 'game_session_dao.g.dart';
|
||||
|
||||
@DriftAccessor(tables: [])
|
||||
class GameSessionDao extends DatabaseAccessor<AppDatabase>
|
||||
with _$GameSessionDaoMixin {
|
||||
GameSessionDao(super.db);
|
||||
}
|
||||
6
lib/data/db/dao/game_session_dao.g.dart
Normal file
6
lib/data/db/dao/game_session_dao.g.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'game_session_dao.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$GameSessionDaoMixin on DatabaseAccessor<AppDatabase> {}
|
||||
10
lib/data/db/dao/player_scores_dao.dart
Normal file
10
lib/data/db/dao/player_scores_dao.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'package:cabo_counter/data/db/database.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
part 'player_scores_dao.g.dart';
|
||||
|
||||
@DriftAccessor(tables: [])
|
||||
class PlayerScoresDao extends DatabaseAccessor<AppDatabase>
|
||||
with _$PlayerScoresDaoMixin {
|
||||
PlayerScoresDao(super.db);
|
||||
}
|
||||
6
lib/data/db/dao/player_scores_dao.g.dart
Normal file
6
lib/data/db/dao/player_scores_dao.g.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'player_scores_dao.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$PlayerScoresDaoMixin on DatabaseAccessor<AppDatabase> {}
|
||||
9
lib/data/db/dao/players_dao.dart
Normal file
9
lib/data/db/dao/players_dao.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
import 'package:cabo_counter/data/db/database.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
part 'players_dao.g.dart';
|
||||
|
||||
@DriftAccessor(tables: [])
|
||||
class PlayersDao extends DatabaseAccessor<AppDatabase> with _$PlayersDaoMixin {
|
||||
PlayersDao(super.db);
|
||||
}
|
||||
6
lib/data/db/dao/players_dao.g.dart
Normal file
6
lib/data/db/dao/players_dao.g.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'players_dao.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$PlayersDaoMixin on DatabaseAccessor<AppDatabase> {}
|
||||
10
lib/data/db/dao/round_scores_dao.dart
Normal file
10
lib/data/db/dao/round_scores_dao.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'package:cabo_counter/data/db/database.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
part 'round_scores_dao.g.dart';
|
||||
|
||||
@DriftAccessor(tables: [])
|
||||
class RoundScoresDao extends DatabaseAccessor<AppDatabase>
|
||||
with _$RoundScoresDaoMixin {
|
||||
RoundScoresDao(super.db);
|
||||
}
|
||||
6
lib/data/db/dao/round_scores_dao.g.dart
Normal file
6
lib/data/db/dao/round_scores_dao.g.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'round_scores_dao.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$RoundScoresDaoMixin on DatabaseAccessor<AppDatabase> {}
|
||||
9
lib/data/db/dao/rounds_dao.dart
Normal file
9
lib/data/db/dao/rounds_dao.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
import 'package:cabo_counter/data/db/database.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
part 'rounds_dao.g.dart';
|
||||
|
||||
@DriftAccessor(tables: [])
|
||||
class RoundsDao extends DatabaseAccessor<AppDatabase> with _$RoundsDaoMixin {
|
||||
RoundsDao(super.db);
|
||||
}
|
||||
6
lib/data/db/dao/rounds_dao.g.dart
Normal file
6
lib/data/db/dao/rounds_dao.g.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'rounds_dao.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$RoundsDaoMixin on DatabaseAccessor<AppDatabase> {}
|
||||
33
lib/data/db/database.dart
Normal file
33
lib/data/db/database.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:cabo_counter/data/db/tables/game_session_table.dart';
|
||||
import 'package:cabo_counter/data/db/tables/player_scores.dart';
|
||||
import 'package:cabo_counter/data/db/tables/players_table.dart';
|
||||
import 'package:cabo_counter/data/db/tables/round_scores_table.dart';
|
||||
import 'package:cabo_counter/data/db/tables/rounds_table.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift_flutter/drift_flutter.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
part 'database.g.dart';
|
||||
|
||||
@DriftDatabase(tables: [
|
||||
GameSessionTable,
|
||||
PlayerScoresTable,
|
||||
PlayersTable,
|
||||
RoundScoresTable,
|
||||
RoundsTable
|
||||
])
|
||||
class AppDatabase extends _$AppDatabase {
|
||||
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
|
||||
|
||||
@override
|
||||
int get schemaVersion => 1;
|
||||
|
||||
static QueryExecutor _openConnection() {
|
||||
return driftDatabase(
|
||||
name: 'cabo-counter_database',
|
||||
native: const DriftNativeOptions(
|
||||
databaseDirectory: getApplicationSupportDirectory,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
3293
lib/data/db/database.g.dart
Normal file
3293
lib/data/db/database.g.dart
Normal file
File diff suppressed because it is too large
Load Diff
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};
|
||||
}
|
||||
@@ -2,7 +2,7 @@ name: cabo_counter
|
||||
description: "Mobile app for the card game Cabo"
|
||||
publish_to: 'none'
|
||||
|
||||
version: 0.3.2+244
|
||||
version: 0.3.2+245
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.4
|
||||
|
||||
Reference in New Issue
Block a user