This commit is contained in:
+5
-1
@@ -44,7 +44,11 @@ extension JaDBConnection on DatabaseExecutor {
|
||||
pageSize: pageSize,
|
||||
);
|
||||
|
||||
///
|
||||
/// Filter a list of word IDs, and return the ones that are listed in the word dictionary.
|
||||
Future<Set<int>> jadbFilterWordIds(Iterable<int> ids) =>
|
||||
filterWordIdsWithDbConnection(this, ids);
|
||||
|
||||
/// Get a word by its ID. Returns null if no result is found for the given ID.
|
||||
Future<WordSearchResult?> jadbGetWordById(int id) =>
|
||||
getWordByIdWithDbConnection(this, id);
|
||||
|
||||
|
||||
@@ -96,6 +96,24 @@ Future<int?> searchWordCountWithDbConnection(
|
||||
return entryIdCount;
|
||||
}
|
||||
|
||||
Future<Set<int>> filterWordIdsWithDbConnection(
|
||||
DatabaseExecutor connection,
|
||||
Iterable<int> ids,
|
||||
) async {
|
||||
if (ids.isEmpty) {
|
||||
return {};
|
||||
}
|
||||
|
||||
final Set<int> filteredIds = await connection
|
||||
.rawQuery(
|
||||
'SELECT "entryId" FROM "${JMdictTableNames.entry}" WHERE "entryId" IN (${ids.map((_) => '?').join(',')})',
|
||||
ids.toList(),
|
||||
)
|
||||
.then((rows) => rows.map((row) => row['entryId'] as int).toSet());
|
||||
|
||||
return filteredIds;
|
||||
}
|
||||
|
||||
/// Fetches a single word by its entry ID, returning null if not found.
|
||||
Future<WordSearchResult?> getWordByIdWithDbConnection(
|
||||
DatabaseExecutor connection,
|
||||
|
||||
Reference in New Issue
Block a user