25 lines
1.1 KiB
Dart
25 lines
1.1 KiB
Dart
import 'package:drift/drift.dart';
|
|
import 'package:sendtrain/database/database.dart';
|
|
|
|
part 'action_sets_dao.g.dart';
|
|
|
|
@DriftAccessor(tables: [ActionSets])
|
|
class ActionSetsDao extends DatabaseAccessor<AppDatabase>
|
|
with _$ActionSetsDaoMixin {
|
|
ActionSetsDao(super.db);
|
|
|
|
// Future<Session> find(int id) => (select(sessions)..where((session) => session.id.equals(id) )).getSingle();
|
|
// Stream<Session> watchSession(int id) => (select(sessions)..where((session) => session.id.equals(id) )).watchSingle();
|
|
// Future<List<Session>> all() => select(sessions).get();
|
|
// Stream<List<Session>> watch() => select(sessions).watch();
|
|
// Future createOrUpdate(SessionsCompanion session) => into(sessions).insertOnConflictUpdate(session);
|
|
// Future replace(Session session) => update(sessions).replace(session);
|
|
// Future remove(Session session) => delete(sessions).delete(session);
|
|
|
|
Future<List<ActionSet>> fromSession(Session session) async {
|
|
return await (select(actionSets)
|
|
..where((actionSet) => actionSet.sessionId.equals(session.id))..orderBy([(t) => OrderingTerm.asc(actionSets.position)]))
|
|
.get();
|
|
}
|
|
}
|