mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibWeb/IDB: Implement IDBObjectStore::createIndex
This commit is contained in:
parent
a235dd4300
commit
3367352991
Notes:
github-actions[bot]
2025-04-09 17:50:46 +00:00
Author: https://github.com/stelar7
Commit: 3367352991
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4178
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/AtkinsSJ
7 changed files with 88 additions and 14 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibGC/Heap.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/IndexedDB/IDBTransaction.h>
|
||||
|
@ -13,6 +14,11 @@
|
|||
|
||||
namespace Web::IndexedDB {
|
||||
|
||||
struct IDBIndexParameters {
|
||||
bool unique { false };
|
||||
bool multi_entry { false };
|
||||
};
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#object-store-interface
|
||||
// https://w3c.github.io/IndexedDB/#object-store-handle-construct
|
||||
class IDBObjectStore : public Bindings::PlatformObject {
|
||||
|
@ -23,14 +29,17 @@ public:
|
|||
virtual ~IDBObjectStore() override;
|
||||
[[nodiscard]] static GC::Ref<IDBObjectStore> create(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBTransaction>);
|
||||
|
||||
JS::Value key_path() const;
|
||||
GC::Ref<IDBTransaction> transaction() const { return m_transaction; }
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#dom-idbobjectstore-autoincrement
|
||||
// The autoIncrement getter steps are to return true if this’s object store has a key generator, and false otherwise.
|
||||
bool auto_increment() const { return m_store->key_generator().has_value(); }
|
||||
JS::Value key_path() const;
|
||||
String name() const { return m_name; }
|
||||
WebIDL::ExceptionOr<void> set_name(String const& value);
|
||||
GC::Ref<IDBTransaction> transaction() const { return m_transaction; }
|
||||
GC::Ref<ObjectStore> store() const { return m_store; }
|
||||
AK::HashMap<String, GC::Ref<Index>>& index_set() { return m_indexes; }
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<IDBIndex>> create_index(String const&, KeyPath, IDBIndexParameters options);
|
||||
|
||||
protected:
|
||||
explicit IDBObjectStore(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBTransaction>);
|
||||
|
@ -44,6 +53,9 @@ private:
|
|||
|
||||
// An object store handle has a name, which is initialized to the name of the associated object store when the object store handle is created.
|
||||
String m_name;
|
||||
|
||||
// An object store handle has an index set
|
||||
AK::HashMap<String, GC::Ref<Index>> m_indexes;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue