fetchAll method
Fetches all records matching a category and tag filter.
Throws an AskarSessionException if the session is closed. Returns a list of EntryObject containing the fetched records.
Implementation
Future<List<EntryObject>> fetchAll({
required String category,
bool forUpdate = false,
int? limit,
Map<String, dynamic>? tagFilter,
bool isJson = false,
String? orderBy,
bool? descending,
}) async {
_throwOnNullHandle('Cannot fetch all from a closed session');
EntryListHandle? entryListHandle;
try {
final fetchAllResult = await askarSessionFetchAll(
handle!,
category,
forUpdate: forUpdate,
tagFilter: tagFilter,
limit: limit,
);
if (!fetchAllResult.errorCode.isSuccess()) {
return [];
}
entryListHandle = fetchAllResult.value;
return EntryList(handle: entryListHandle).toArray(valuesAreJson: isJson);
} catch (e) {
throw AskarSessionException('Failed to fetch entries: $e');
} finally {
if (entryListHandle != null) {
entryListHandle.free();
}
}
}