72 lines
2.8 KiB
Dart
72 lines
2.8 KiB
Dart
import 'package:jadb/models/kanji_search/kanji_search_result.dart';
|
|
import 'package:jadb/models/verify_tables.dart';
|
|
import 'package:jadb/models/word_search/word_search_result.dart';
|
|
import 'package:jadb/search/filter_kanji.dart';
|
|
import 'package:jadb/search/kanji_search.dart';
|
|
import 'package:jadb/search/radical_search.dart';
|
|
import 'package:jadb/search/word_search/word_search.dart';
|
|
import 'package:sqflite_common/sqlite_api.dart';
|
|
|
|
extension JaDBConnection on DatabaseExecutor {
|
|
/// Ensure that the database contain all JaDB tables.
|
|
///
|
|
/// This will throw an exception if any of the tables are missing.
|
|
Future<void> jadbVerifyTables() => verifyTablesWithDbConnection(this);
|
|
|
|
/// Search for a kanji in the database.
|
|
Future<KanjiSearchResult?> jadbSearchKanji(String kanji) =>
|
|
searchKanjiWithDbConnection(this, kanji);
|
|
|
|
/// Search for a kanji in the database.
|
|
Future<Map<String, KanjiSearchResult>> jadbGetManyKanji(Set<String> kanji) =>
|
|
searchManyKanjiWithDbConnection(this, kanji);
|
|
|
|
/// Filter a list of characters, and return the ones that are listed in the kanji dictionary.
|
|
Future<List<String>> filterKanji(
|
|
List<String> kanji, {
|
|
bool deduplicate = false,
|
|
}) => filterKanjiWithDbConnection(this, kanji, deduplicate);
|
|
|
|
/// Search for a word in the database.
|
|
Future<List<WordSearchResult>?> jadbSearchWord(
|
|
String word, {
|
|
SearchMode searchMode = SearchMode.Auto,
|
|
int page = 0,
|
|
int? pageSize,
|
|
}) => searchWordWithDbConnection(
|
|
this,
|
|
word,
|
|
searchMode: searchMode,
|
|
page: page,
|
|
pageSize: pageSize,
|
|
);
|
|
|
|
///
|
|
Future<WordSearchResult?> jadbGetWordById(int id) =>
|
|
getWordByIdWithDbConnection(this, id);
|
|
|
|
/// Get a list of words by their IDs.
|
|
///
|
|
/// IDs for which no result is found are omitted from the returned value.
|
|
Future<Map<int, WordSearchResult>> jadbGetManyWordsByIds(Set<int> ids) =>
|
|
getWordsByIdsWithDbConnection(this, ids);
|
|
|
|
/// Search for a word in the database, and return the count of results.
|
|
Future<int?> jadbSearchWordCount(
|
|
String word, {
|
|
SearchMode searchMode = SearchMode.Auto,
|
|
}) => searchWordCountWithDbConnection(this, word, searchMode: searchMode);
|
|
|
|
/// Given a list of radicals, search which kanji contains all
|
|
/// of the radicals, find their other radicals, and return those.
|
|
/// This is used to figure out which remaining combinations of radicals
|
|
/// the user can search for without getting zero results.
|
|
Future<List<String>> jadbSearchRemainingRadicals(List<String> radicals) =>
|
|
searchRemainingRadicalsWithDbConnection(this, radicals);
|
|
|
|
/// Given a list of radicals, search which kanji contains all
|
|
/// of the radicals, and return those.
|
|
Future<List<String>> jadbSearchKanjiByRadicals(List<String> radicals) =>
|
|
searchKanjiByRadicalsWithDbConnection(this, radicals);
|
|
}
|