implemented dao's for every table
This commit is contained in:
@@ -1,4 +1,36 @@
|
||||
import 'package:game_tracker/data/database.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
extension ResultPlacementDao on AppDatabase {}
|
||||
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> updateResultPlacement(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)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user