mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 21:12:08 +02:00
LibWeb/IDB: Implement IDBObjectStore::get_all_records
This commit is contained in:
committed by
Jelle Raaijmakers
parent
6f756f7f6c
commit
559b9dbd83
Notes:
github-actions[bot]
2025-08-27 14:15:18 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/559b9dbd830 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5385 Reviewed-by: https://github.com/gmta ✅
@@ -731,4 +731,32 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBObjectStore::get_all_keys(Optional<J
|
||||
return result;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBObjectStore::get_all_records(IDBGetAllOptions const& options)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
// 1. Let transaction be this’s transaction.
|
||||
auto transaction = this->transaction();
|
||||
|
||||
// 2. Let store be this’s object store.
|
||||
auto store = this->store();
|
||||
|
||||
// FIXME: 3. If store has been deleted, throw an "InvalidStateError" DOMException.
|
||||
|
||||
// 4. If transaction’s state is not active, then throw a "TransactionInactiveError" DOMException.
|
||||
if (!transaction->is_active())
|
||||
return WebIDL::TransactionInactiveError::create(realm, "Transaction is not active while getting all records"_utf16);
|
||||
|
||||
// 5. Let range be the result of converting a value to a key range with options["query"]. Rethrow any exceptions.
|
||||
auto range = TRY(convert_a_value_to_a_key_range(realm, options.query));
|
||||
|
||||
// 6. Let operation be an algorithm to run retrieve multiple items from an object store with the current Realm record, store, range, "record", options["direction"], and options["count"] if given.
|
||||
auto operation = GC::Function<WebIDL::ExceptionOr<JS::Value>()>::create(realm.heap(), [&realm, store, range, options] -> WebIDL::ExceptionOr<JS::Value> {
|
||||
return retrieve_multiple_items_from_an_object_store(realm, store, range, RecordKind::Record, options.direction, options.count);
|
||||
});
|
||||
|
||||
// 7. Return the result (an IDBRequest) of running asynchronously execute a request with this and operation.
|
||||
return asynchronously_execute_a_request(realm, GC::Ref(*this), operation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user