Jisho-Study-Tool/lib/models/history/search.dart

31 lines
552 B
Dart
Raw Normal View History

2021-08-03 22:02:42 +02:00
import 'package:objectbox/objectbox.dart';
import './kanji_query.dart';
import './word_query.dart';
@Entity()
class Search {
int id;
@Property(type: PropertyType.date)
late final DateTime timestamp;
final wordQuery = ToOne<WordQuery>();
final kanjiQuery = ToOne<KanjiQuery>();
Search({
this.id = 0,
2021-12-01 23:09:53 +01:00
required this.timestamp,
});
2021-08-03 22:02:42 +02:00
bool isKanji() {
// // TODO: better error message
2021-12-01 23:09:53 +01:00
if (wordQuery.target == null && kanjiQuery.target == null)
2021-08-03 22:02:42 +02:00
throw Exception();
2021-12-01 23:09:53 +01:00
return wordQuery.target == null;
2021-08-03 22:02:42 +02:00
}
2021-12-01 23:09:53 +01:00
}