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

30 lines
570 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,
required this.timestamp
}); // {
bool isKanji() {
// // TODO: better error message
if (this.wordQuery.target == null && this.kanjiQuery.target == null)
throw Exception();
return this.wordQuery.target == null;
}
}