27 lines
858 B
Dart
27 lines
858 B
Dart
import 'package:drift/drift.dart';
|
|
import 'package:sendtrain/database/database.dart';
|
|
|
|
part 'sessions_dao.g.dart';
|
|
|
|
@DriftAccessor(tables: [Sessions])
|
|
class SessionsDao extends DatabaseAccessor<AppDatabase> with _$SessionsDaoMixin {
|
|
SessionsDao(super.db);
|
|
|
|
Future<List<Session>> all() async {
|
|
return await select(sessions).get();
|
|
}
|
|
|
|
// Future<List<Session>> remove
|
|
|
|
// Future<List<Session>> all() => select(sessions).get();
|
|
// Stream<List<Session>> watch() => select(sessions).watch();
|
|
// Future insert(Session session) => into(sessions).insert(session);
|
|
// Future replace(Session session) => update(sessions).replace(session);
|
|
Future remove(Session session) => delete(sessions).delete(session);
|
|
|
|
Future<Session> find(int id) async {
|
|
return await (select(sessions)..where((session) => session.id.equals(id) )).getSingle();
|
|
}
|
|
|
|
|
|
} |