Compare commits
11 Commits
v.0.0.1-al
...
5a33bdc24d
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a33bdc24d | |||
| be33f2c3d8 | |||
| 11b7b37b4e | |||
| bd28912b97 | |||
| a989c23633 | |||
| d5b040b177 | |||
| 3ab5305bba | |||
| cb0d5727c5 | |||
| c617072a35 | |||
| 35cd9213af | |||
| ff2b91e77e |
30
lib/data/dao/game_dao.dart
Normal file
30
lib/data/dao/game_dao.dart
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import 'package:game_tracker/data/database.dart';
|
||||||
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
|
extension GameDao on AppDatabase {
|
||||||
|
Future<List<GameTableData>> getAllGames() async {
|
||||||
|
return await select(gameTable).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<GameTableData> getGameById(int id) async {
|
||||||
|
return await (select(
|
||||||
|
gameTable,
|
||||||
|
)..where((ga) => ga.id.equals(id))).getSingle();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addGame(int id, String name) async {
|
||||||
|
await into(
|
||||||
|
gameTable,
|
||||||
|
).insert(GameTableCompanion.insert(name: name));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteGameById(int id) async {
|
||||||
|
await (delete(gameTable)..where((ga) => ga.id.equals(id))).go();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateGameNameById(int id, String newName) async {
|
||||||
|
await (update(gameTable)..where((ga) => ga.id.equals(id))).write(
|
||||||
|
GameTableCompanion(name: Value(newName)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
lib/data/dao/group_dao.dart
Normal file
30
lib/data/dao/group_dao.dart
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import 'package:game_tracker/data/database.dart';
|
||||||
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
|
extension GroupDao on AppDatabase {
|
||||||
|
Future<List<GroupTableData>> getAllGroups() async {
|
||||||
|
return await select(groupTable).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<GroupTableData> getGroupById(String id) async {
|
||||||
|
return await (select(
|
||||||
|
groupTable,
|
||||||
|
)..where((gr) => gr.id.equals(id))).getSingle();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addGroup(String id, String name) async {
|
||||||
|
await into(
|
||||||
|
groupTable,
|
||||||
|
).insert(GroupTableCompanion.insert(id: id, name: name));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteGroupById(String id) async {
|
||||||
|
await (delete(groupTable)..where((gr) => gr.id.equals(id))).go();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateGroupNameById(String id, String newName) async {
|
||||||
|
await (update(groupTable)..where((gr) => gr.id.equals(id))).write(
|
||||||
|
GroupTableCompanion(name: Value(newName)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
23
lib/data/dao/match_dao.dart
Normal file
23
lib/data/dao/match_dao.dart
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import 'package:game_tracker/data/database.dart';
|
||||||
|
|
||||||
|
extension MatchDao on AppDatabase {
|
||||||
|
Future<List<MatchTableData>> getAllMatches() async {
|
||||||
|
return await select(matchTable).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<MatchTableData> getMatchById(String id) async {
|
||||||
|
return await (select(
|
||||||
|
matchTable,
|
||||||
|
)..where((m) => m.id.equals(id))).getSingle();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addMatch(String matchId, int gameId, String groupId, DateTime createdAt) async {
|
||||||
|
await into(
|
||||||
|
matchTable,
|
||||||
|
).insert(MatchTableCompanion.insert(id: matchId, gameId: gameId, groupId: groupId, createdAt: createdAt));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteMatchById(String id) async {
|
||||||
|
await (delete(matchTable)..where((m) => m.id.equals(id))).go();
|
||||||
|
}
|
||||||
|
}
|
||||||
36
lib/data/dao/result_placement_dao.dart
Normal file
36
lib/data/dao/result_placement_dao.dart
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import 'package:game_tracker/data/database.dart';
|
||||||
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
|
extension ResultPlacementDao on AppDatabase {
|
||||||
|
Future<List<ResultPlacementTableData>> getAllResultPlacements() async {
|
||||||
|
return await select(resultPlacementTable).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<ResultPlacementTableData>> getAllResultPlacementsByMatchId(String matchId) async {
|
||||||
|
return await (select(
|
||||||
|
resultPlacementTable,
|
||||||
|
)..where((rP) => rP.matchId.equals(matchId))).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<ResultPlacementTableData>> getAllResultPlacementsByUserId(String userId) async {
|
||||||
|
return await (select(
|
||||||
|
resultPlacementTable,
|
||||||
|
)..where((rP) => rP.matchId.equals(userId))).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addResultPlacement(String matchId, String userId, int placement) async {
|
||||||
|
await into(
|
||||||
|
resultPlacementTable,
|
||||||
|
).insert(ResultPlacementTableCompanion.insert(matchId: matchId, userId: userId, placement: placement));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteResultPlacementsByMatchId(String matchId) async {
|
||||||
|
await (delete(resultPlacementTable)..where((rP) => rP.matchId.equals(matchId))).go();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateResultPlacementByMatchIdAndUserId(String matchId, String userId, int placement) async {
|
||||||
|
await (update(resultPlacementTable)..where((rP) => rP.matchId.equals(matchId))..where((rP) => rP.userId.equals(userId))).write(
|
||||||
|
ResultPlacementTableCompanion(placement: Value(placement)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
lib/data/dao/result_score_dao.dart
Normal file
36
lib/data/dao/result_score_dao.dart
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import 'package:game_tracker/data/database.dart';
|
||||||
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
|
extension ResultScoreDao on AppDatabase {
|
||||||
|
Future<List<ResultScoreTableData>> getAllResultScores() async {
|
||||||
|
return await select(resultScoreTable).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<ResultScoreTableData>> getAllResultScoresByMatchId(String matchId) async {
|
||||||
|
return await (select(
|
||||||
|
resultScoreTable,
|
||||||
|
)..where((rS) => rS.matchId.equals(matchId))).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<ResultScoreTableData>> getAllResultScoresByUserId(String userId) async {
|
||||||
|
return await (select(
|
||||||
|
resultScoreTable,
|
||||||
|
)..where((rS) => rS.matchId.equals(userId))).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addResultScore(String matchId, String userId, int score) async {
|
||||||
|
await into(
|
||||||
|
resultScoreTable,
|
||||||
|
).insert(ResultScoreTableCompanion.insert(matchId: matchId, userId: userId, score: score));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteResultScoresByMatchId(String matchId) async {
|
||||||
|
await (delete(resultScoreTable)..where((rS) => rS.matchId.equals(matchId))).go();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateResultScoreByMatchIdAndUserId(String matchId, String userId, int score) async {
|
||||||
|
await (update(resultScoreTable)..where((rS) => rS.matchId.equals(matchId))..where((rS) => rS.userId.equals(userId))).write(
|
||||||
|
ResultScoreTableCompanion(score: Value(score)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
lib/data/dao/result_win_dao.dart
Normal file
36
lib/data/dao/result_win_dao.dart
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import 'package:game_tracker/data/database.dart';
|
||||||
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
|
extension ResultWinDao on AppDatabase {
|
||||||
|
Future<List<ResultWinTableData>> getAllResultWins() async {
|
||||||
|
return await select(resultWinTable).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<ResultWinTableData> getResultWinByMatchId(String matchId) async {
|
||||||
|
return await (select(
|
||||||
|
resultWinTable,
|
||||||
|
)..where((rW) => rW.matchId.equals(matchId))).getSingle();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<ResultWinTableData>> getAllResultWinsByUserId(String userId) async {
|
||||||
|
return await (select(
|
||||||
|
resultWinTable,
|
||||||
|
)..where((rW) => rW.matchId.equals(userId))).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addResultWin(String matchId, String winnerId) async {
|
||||||
|
await into(
|
||||||
|
resultWinTable,
|
||||||
|
).insert(ResultWinTableCompanion.insert(matchId: matchId, winnerId: winnerId));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteResultWinByMatchId(String matchId) async {
|
||||||
|
await (delete(resultWinTable)..where((rW) => rW.matchId.equals(matchId))).go();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateResultWinByMatchIdAndUserId(String matchId, String newWinnerId) async {
|
||||||
|
await (update(resultWinTable)..where((rW) => rW.matchId.equals(matchId))).write(
|
||||||
|
ResultWinTableCompanion(winnerId: Value(newWinnerId)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
lib/data/dao/user_dao.dart
Normal file
26
lib/data/dao/user_dao.dart
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import 'package:game_tracker/data/database.dart';
|
||||||
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
|
extension UserDao on AppDatabase {
|
||||||
|
Future<List<UserTableData>> getAllUsers() async {
|
||||||
|
return await select(userTable).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<UserTableData> getUserById(String id) async {
|
||||||
|
return await (select(userTable)..where((u) => u.id.equals(id))).getSingle();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addUser(String id, String name) async {
|
||||||
|
await into(userTable).insert(UserTableCompanion.insert(id: id, name: name));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteUserById(String id) async {
|
||||||
|
await (delete(userTable)..where((u) => u.id.equals(id))).go();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateUsernameById(String id, String newName) async {
|
||||||
|
await (update(userTable)..where((u) => u.id.equals(id))).write(
|
||||||
|
UserTableCompanion(name: Value(newName)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
33
lib/data/dao/user_group_dao.dart
Normal file
33
lib/data/dao/user_group_dao.dart
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import 'package:game_tracker/data/database.dart';
|
||||||
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
|
extension UserGroupDao on AppDatabase {
|
||||||
|
Future<List<UserGroupTableData>> getAllUsersAndGroups() async {
|
||||||
|
return await select(userGroupTable).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<UserGroupTableData>> getUsersGroups(String userId) async {
|
||||||
|
return await (select(
|
||||||
|
userGroupTable,
|
||||||
|
)..where((uG) => uG.userId.equals(userId))).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<UserGroupTableData>> getGroupsUsers(String groupId) async {
|
||||||
|
return await (select(
|
||||||
|
userGroupTable,
|
||||||
|
)..where((uG) => uG.groupId.equals(groupId))).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addUserToGroup(String userId, String groupId) async {
|
||||||
|
await into(
|
||||||
|
userGroupTable,
|
||||||
|
).insert(UserGroupTableCompanion.insert(userId: userId, groupId: groupId));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> removeUserFromGroup(String userId, String groupId) async {
|
||||||
|
await (delete(
|
||||||
|
userGroupTable,
|
||||||
|
)..where((uG) => uG.userId.equals(userId) & uG.groupId.equals(groupId)))
|
||||||
|
.go();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,34 +1,29 @@
|
|||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
import 'package:drift_flutter/drift_flutter.dart';
|
import 'package:drift_flutter/drift_flutter.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
import 'package:game_tracker/data/tables/user_table.dart';
|
||||||
|
import 'package:game_tracker/data/tables/group_table.dart';
|
||||||
|
import 'package:game_tracker/data/tables/user_group_table.dart';
|
||||||
|
import 'package:game_tracker/data/tables/game_table.dart';
|
||||||
|
import 'package:game_tracker/data/tables/match_table.dart';
|
||||||
|
import 'package:game_tracker/data/tables/result_score_table.dart';
|
||||||
|
import 'package:game_tracker/data/tables/result_win_table.dart';
|
||||||
|
import 'package:game_tracker/data/tables/result_placement_table.dart';
|
||||||
|
|
||||||
part 'database.g.dart';
|
part 'database.g.dart';
|
||||||
|
|
||||||
class User extends Table {
|
@DriftDatabase(
|
||||||
TextColumn get id => text()();
|
tables: [
|
||||||
TextColumn get name => text()();
|
UserTable,
|
||||||
|
GroupTable,
|
||||||
@override
|
UserGroupTable,
|
||||||
Set<Column<Object>> get primaryKey => {id};
|
GameTable,
|
||||||
}
|
MatchTable,
|
||||||
|
ResultScoreTable,
|
||||||
class Group extends Table {
|
ResultWinTable,
|
||||||
TextColumn get id => text()();
|
ResultPlacementTable,
|
||||||
TextColumn get name => text()();
|
],
|
||||||
|
)
|
||||||
@override
|
|
||||||
Set<Column<Object>> get primaryKey => {id};
|
|
||||||
}
|
|
||||||
|
|
||||||
class UserGroup extends Table {
|
|
||||||
TextColumn get userId => text().references(User, #id)();
|
|
||||||
TextColumn get groupId => text().references(Group, #id)();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Set<Column<Object>> get primaryKey => {userId, groupId};
|
|
||||||
}
|
|
||||||
|
|
||||||
@DriftDatabase(tables: [User, Group, UserGroup])
|
|
||||||
class AppDatabase extends _$AppDatabase {
|
class AppDatabase extends _$AppDatabase {
|
||||||
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
|
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
|
||||||
|
|
||||||
@@ -43,4 +38,4 @@ class AppDatabase extends _$AppDatabase {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,28 +0,0 @@
|
|||||||
import 'package:game_tracker/data/database.dart';
|
|
||||||
import 'package:drift/drift.dart';
|
|
||||||
|
|
||||||
extension GroupMethods on AppDatabase {
|
|
||||||
Future<List<GroupData>> getAllGroups() async {
|
|
||||||
return await select(group).get();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<GroupData> getGroupById(String id) async {
|
|
||||||
return await (select(group)..where((g) => g.id.equals(id))).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> addGroup(String id, String name) async {
|
|
||||||
await into(group).insert(
|
|
||||||
GroupCompanion.insert(id: id, name: name),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> deleteGroup(String id) async {
|
|
||||||
await (delete(group)..where((g) => g.id.equals(id))).go();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> updateGroupname(String id, String newName) async {
|
|
||||||
await (update(group)..where((g) => g.id.equals(id))).write(
|
|
||||||
GroupCompanion(name: Value(newName)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
import 'package:game_tracker/data/database.dart';
|
|
||||||
import 'package:drift/drift.dart';
|
|
||||||
|
|
||||||
extension UserMethods on AppDatabase {
|
|
||||||
Future<List<UserData>> getAllUsers() async {
|
|
||||||
return await select(user).get();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<UserData> getUserById(String id) async {
|
|
||||||
return await (select(user)..where((u) => u.id.equals(id))).getSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> addUser(String id, String name) async {
|
|
||||||
await into(user).insert(
|
|
||||||
UserCompanion.insert(id: id, name: name),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> deleteUser(String id) async {
|
|
||||||
await (delete(user)..where((u) => u.id.equals(id))).go();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> updateUsername(String id, String newName) async {
|
|
||||||
await (update(user)..where((u) => u.id.equals(id))).write(
|
|
||||||
UserCompanion(name: Value(newName)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
import 'package:game_tracker/data/database.dart';
|
|
||||||
import 'package:drift/drift.dart';
|
|
||||||
|
|
||||||
extension UserGroupMethods on AppDatabase {
|
|
||||||
Future<List<UserGroupData>> getAllUsersAndGroups() async {
|
|
||||||
return await select(userGroup).get();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<UserGroupData>> getUsersGroups(String userId) async {
|
|
||||||
return await (select(userGroup)..where((uG) => uG.userId.equals(userId))).get();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<UserGroupData>> getGroupsUsers(String groupId) async {
|
|
||||||
return await (select(userGroup)..where((uG) => uG.groupId.equals(groupId))).get();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> addUserToGroup(String userId, String groupId) async {
|
|
||||||
await into(userGroup).insert(
|
|
||||||
UserGroupCompanion.insert(userId: userId, groupId: groupId),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> removeUserFromGroup(String userId, String groupId) async {
|
|
||||||
await (delete(userGroup)..where((uG) => uG.userId.equals(userId) & uG.groupId.equals(groupId))).go();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
6
lib/data/tables/game_table.dart
Normal file
6
lib/data/tables/game_table.dart
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
|
class GameTable extends Table {
|
||||||
|
IntColumn get id => integer().autoIncrement()();
|
||||||
|
TextColumn get name => text()();
|
||||||
|
}
|
||||||
9
lib/data/tables/group_table.dart
Normal file
9
lib/data/tables/group_table.dart
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
|
class GroupTable extends Table {
|
||||||
|
TextColumn get id => text()();
|
||||||
|
TextColumn get name => text()();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Set<Column<Object>> get primaryKey => {id};
|
||||||
|
}
|
||||||
13
lib/data/tables/match_table.dart
Normal file
13
lib/data/tables/match_table.dart
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import 'package:drift/drift.dart';
|
||||||
|
import 'game_table.dart';
|
||||||
|
import 'group_table.dart';
|
||||||
|
|
||||||
|
class MatchTable extends Table {
|
||||||
|
TextColumn get id => text()();
|
||||||
|
IntColumn get gameId => integer().references(GameTable, #id)();
|
||||||
|
TextColumn get groupId => text().references(GroupTable, #id)();
|
||||||
|
DateTimeColumn get createdAt => dateTime()();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Set<Column<Object>> get primaryKey => {id};
|
||||||
|
}
|
||||||
12
lib/data/tables/result_placement_table.dart
Normal file
12
lib/data/tables/result_placement_table.dart
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import 'package:drift/drift.dart';
|
||||||
|
import 'match_table.dart';
|
||||||
|
import 'user_table.dart';
|
||||||
|
|
||||||
|
class ResultPlacementTable extends Table {
|
||||||
|
TextColumn get matchId => text().references(MatchTable, #id)();
|
||||||
|
TextColumn get userId => text().references(UserTable, #id)();
|
||||||
|
IntColumn get placement => integer()();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Set<Column<Object>> get primaryKey => {matchId, userId};
|
||||||
|
}
|
||||||
12
lib/data/tables/result_score_table.dart
Normal file
12
lib/data/tables/result_score_table.dart
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import 'package:drift/drift.dart';
|
||||||
|
import 'match_table.dart';
|
||||||
|
import 'user_table.dart';
|
||||||
|
|
||||||
|
class ResultScoreTable extends Table {
|
||||||
|
TextColumn get matchId => text().references(MatchTable, #id)();
|
||||||
|
TextColumn get userId => text().references(UserTable, #id)();
|
||||||
|
IntColumn get score => integer()();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Set<Column<Object>> get primaryKey => {matchId, userId};
|
||||||
|
}
|
||||||
11
lib/data/tables/result_win_table.dart
Normal file
11
lib/data/tables/result_win_table.dart
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import 'package:drift/drift.dart';
|
||||||
|
import 'match_table.dart';
|
||||||
|
import 'user_table.dart';
|
||||||
|
|
||||||
|
class ResultWinTable extends Table {
|
||||||
|
TextColumn get matchId => text().references(MatchTable, #id)();
|
||||||
|
TextColumn get winnerId => text().references(UserTable, #id)();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Set<Column<Object>> get primaryKey => {matchId, winnerId};
|
||||||
|
}
|
||||||
11
lib/data/tables/user_group_table.dart
Normal file
11
lib/data/tables/user_group_table.dart
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import 'package:drift/drift.dart';
|
||||||
|
import 'group_table.dart';
|
||||||
|
import 'user_table.dart';
|
||||||
|
|
||||||
|
class UserGroupTable extends Table {
|
||||||
|
TextColumn get userId => text().references(UserTable, #id)();
|
||||||
|
TextColumn get groupId => text().references(GroupTable, #id)();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Set<Column<Object>> get primaryKey => {userId, groupId};
|
||||||
|
}
|
||||||
10
lib/data/tables/user_table.dart
Normal file
10
lib/data/tables/user_table.dart
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
|
class UserTable extends Table {
|
||||||
|
TextColumn get id => text()();
|
||||||
|
TextColumn get name => text()();
|
||||||
|
TextColumn get surname => text().nullable()();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Set<Column<Object>> get primaryKey => {id};
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ void main() {
|
|||||||
create: (context) => AppDatabase(),
|
create: (context) => AppDatabase(),
|
||||||
child: const MyApp(),
|
child: const MyApp(),
|
||||||
dispose: (context, db) => db.close(),
|
dispose: (context, db) => db.close(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user