LibWeb/IDB: Implement IDBDatabase::createObjectStore

This commit is contained in:
stelar7 2025-03-24 20:43:12 +01:00 committed by Jelle Raaijmakers
commit 1057c88fdd
Notes: github-actions[bot] 2025-03-27 15:49:41 +00:00
7 changed files with 102 additions and 10 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com>
* Copyright (c) 2024-2025, stelar7 <dudedbz@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -11,10 +11,19 @@
#include <LibWeb/HTML/DOMStringList.h>
#include <LibWeb/IndexedDB/IDBRequest.h>
#include <LibWeb/IndexedDB/Internal/Database.h>
#include <LibWeb/IndexedDB/Internal/ObjectStore.h>
#include <LibWeb/StorageAPI/StorageKey.h>
namespace Web::IndexedDB {
using KeyPath = Variant<String, Vector<String>>;
// https://w3c.github.io/IndexedDB/#dictdef-idbobjectstoreparameters
struct IDBObjectStoreParameters {
Optional<KeyPath> key_path;
bool auto_increment { false };
};
// FIXME: I'm not sure if this object should do double duty as both the connection and the interface
// but the spec treats it as such...?
// https://w3c.github.io/IndexedDB/#IDBDatabase-interface
@ -44,6 +53,8 @@ public:
[[nodiscard]] ConnectionState state() const { return m_state; }
[[nodiscard]] GC::Ref<Database> associated_database() { return m_associated_database; }
WebIDL::ExceptionOr<GC::Ref<IDBObjectStore>> create_object_store(String const&, IDBObjectStoreParameters const&);
void close();
void set_onabort(WebIDL::CallbackType*);