mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-16 05:51:55 +00:00
LibWeb/IDB: Implement IDBIndex::count
This commit is contained in:
parent
b8bb8345a9
commit
852323009f
Notes:
github-actions[bot]
2025-05-14 15:19:13 +00:00
Author: https://github.com/stelar7
Commit: 852323009f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4727
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/shannonbooth
7 changed files with 54 additions and 4 deletions
|
@ -1453,10 +1453,16 @@ WebIDL::ExceptionOr<GC::Ref<IDBKeyRange>> convert_a_value_to_a_key_range(JS::Rea
|
|||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#count-the-records-in-a-range
|
||||
JS::Value count_the_records_in_a_range(GC::Ref<ObjectStore> source, GC::Ref<IDBKeyRange> range)
|
||||
JS::Value count_the_records_in_a_range(RecordSource source, GC::Ref<IDBKeyRange> range)
|
||||
{
|
||||
// 1. Let count be the number of records, if any, in source’s list of records with key in range.
|
||||
auto count = source->count_records_in_range(range);
|
||||
auto count = source.visit(
|
||||
[range](GC::Ref<ObjectStore> object_store) {
|
||||
return object_store->count_records_in_range(range);
|
||||
},
|
||||
[range](GC::Ref<Index> index) {
|
||||
return index->count_records_in_range(range);
|
||||
});
|
||||
|
||||
// 2. Return count.
|
||||
return JS::Value(count);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue