device_info_table_dao.dart 903 B

123456789101112131415161718192021222324252627
  1. import 'package:drift/drift.dart';
  2. import 'package:lszlgl/drfit/database.dart';
  3. import 'package:lszlgl/drfit/device_info_table.dart';
  4. import 'package:lszlgl/service/user_service.dart';
  5. part 'device_info_table_dao.g.dart';
  6. @DriftAccessor(tables: [DeviceInfoTable])
  7. class DeviceInfoTableDao extends DatabaseAccessor<MyDatabase> {
  8. DeviceInfoTableDao(MyDatabase db) : super(db);
  9. Future<int> addOneDeviceComp(DeviceInfoTableCompanion deviceInfoTableCompanion) async {
  10. return into(db.deviceInfoTable).insert(deviceInfoTableCompanion, mode: InsertMode.insertOrReplace);
  11. }
  12. Future<List<DeviceInfo>> queryAllDeviceInfo() async {
  13. int deviceInfoTableTime = UserService.get().getDeviceInfoTableTime();
  14. return (select(db.deviceInfoTable)
  15. ..where((tbl) => tbl.createdAt.isBiggerThanValue(deviceInfoTableTime))
  16. ..orderBy([(row) => OrderingTerm.asc(row.createdAt)])).get();
  17. }
  18. }