mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
Add recordings
The tables ensembles, roles, recordings and performances as well as corresponding queries and update logic have been added to the database.
This commit is contained in:
parent
554cf4a6ac
commit
4092a91f56
2 changed files with 66 additions and 5 deletions
|
|
@ -30,11 +30,10 @@ class Database extends _$Database {
|
|||
int get schemaVersion => 1;
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration => MigrationStrategy(
|
||||
beforeOpen: (details) async {
|
||||
await customStatement('PRAGMA foreign_keys = ON');
|
||||
}
|
||||
);
|
||||
MigrationStrategy get migration =>
|
||||
MigrationStrategy(beforeOpen: (details) async {
|
||||
await customStatement('PRAGMA foreign_keys = ON');
|
||||
});
|
||||
|
||||
// TODO: Remove this once https://github.com/simolus3/moor/issues/453 is fixed.
|
||||
Selectable<Work> worksByComposer(int id) {
|
||||
|
|
@ -74,4 +73,23 @@ class Database extends _$Database {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> updateEnsemble(Ensemble ensemble) async {
|
||||
await into(ensembles).insert(ensemble, orReplace: true);
|
||||
}
|
||||
|
||||
Future<void> updateRole(Role role) async {
|
||||
await into(roles).insert(role, orReplace: true);
|
||||
}
|
||||
|
||||
Future<void> updateRecording(
|
||||
Recording recording, List<Performance> perfs) async {
|
||||
await transaction(() async {
|
||||
await (delete(performances)..where((p) => p.recording.equals(recording.id))).go();
|
||||
await into(recordings).insert(recording, orReplace: true);
|
||||
for (final perf in perfs) {
|
||||
await into(performances).insert(perf);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue