LibWeb/IDB: Implement IDBDatabase::transaction()

This commit is contained in:
stelar7 2025-04-25 18:08:40 +02:00 committed by Jelle Raaijmakers
commit 61384473ca
Notes: github-actions[bot] 2025-04-28 09:33:04 +00:00
5 changed files with 62 additions and 1 deletions

View file

@ -7,9 +7,11 @@
#pragma once
#include <LibGC/Ptr.h>
#include <LibWeb/Bindings/IDBDatabasePrototype.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/HTML/DOMStringList.h>
#include <LibWeb/IndexedDB/IDBRequest.h>
#include <LibWeb/IndexedDB/IDBTransaction.h>
#include <LibWeb/IndexedDB/Internal/Database.h>
#include <LibWeb/IndexedDB/Internal/ObjectStore.h>
#include <LibWeb/StorageAPI/StorageKey.h>
@ -24,6 +26,11 @@ struct IDBObjectStoreParameters {
bool auto_increment { false };
};
// https://w3c.github.io/IndexedDB/#dictdef-idbtransactionoptions
struct IDBTransactionOptions {
Bindings::IDBTransactionDurability durability = Bindings::IDBTransactionDurability::Default;
};
// 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
@ -66,6 +73,8 @@ public:
WebIDL::ExceptionOr<GC::Ref<IDBObjectStore>> create_object_store(String const&, IDBObjectStoreParameters const&);
WebIDL::ExceptionOr<void> delete_object_store(String const&);
WebIDL::ExceptionOr<GC::Ref<IDBTransaction>> transaction(Variant<String, Vector<String>>, Bindings::IDBTransactionMode = Bindings::IDBTransactionMode::Readonly, IDBTransactionOptions = { .durability = Bindings::IDBTransactionDurability::Default });
void close();
void set_onabort(WebIDL::CallbackType*);