Table of Contents

Class IDBDatabase

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The IDBDatabase interface of the IndexedDB API provides a connection to a database; you can use an IDBDatabase object to open a transaction on your database then create, manipulate, and delete objects (data) in that database. The interface provides the only way to get and manage versions of the database.

[Value("IDBDatabase")]
public class IDBDatabase : EventTarget
Inheritance
IDBDatabase
Inherited Members

Remarks

NOTE

Everything you do in IndexedDB always happens in the context of a transaction, representing interactions with data in the database. All objects in IndexedDB — including object stores, indexes, and cursors — are tied to a particular transaction. Thus, you cannot execute commands, access data, or open anything outside of a transaction.

-Using IndexedDB
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Constructors

IDBDatabase()

public IDBDatabase()

Properties

Name

The name read-only property of the
IDBDatabase interface is a string that contains the
name of the connected database.

[Value("name")]
public string Name { get; }

Property Value

string

A string containing the name of the connected database.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

ObjectStoreNames

The objectStoreNames read-only property of the
IDBDatabase interface is a DOMStringList containing a
list of the names of the object stores currently in the connected database.

[Value("objectStoreNames")]
public DOMStringList ObjectStoreNames { get; }

Property Value

DOMStringList

A DOMStringList containing a list of
the names of the object stores currently
in the connected database.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Onabort

[Value("onabort")]
public EventHandlerNonNull Onabort { get; set; }

Property Value

EventHandlerNonNull

Onclose

[Value("onclose")]
public EventHandlerNonNull Onclose { get; set; }

Property Value

EventHandlerNonNull

Onerror

[Value("onerror")]
public EventHandlerNonNull Onerror { get; set; }

Property Value

EventHandlerNonNull

Onversionchange

[Value("onversionchange")]
public EventHandlerNonNull Onversionchange { get; set; }

Property Value

EventHandlerNonNull

Version

The version property of the IDBDatabase
interface is a 64-bit integer
that contains the version of the connected database.
When a database is first created, this attribute is an empty string.

[Value("version")]
public ulong Version { get; }

Property Value

ulong

An integer containing the version of the connected database.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Methods

Close()

The close() method of the IDBDatabase
interface returns immediately and closes the connection in a separate thread.

[Value("close")]
public GlobalObject.Undefined Close()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

The connection is not actually closed until all transactions created using this
connection are complete. No new transactions can be created for this connection once
this method is called. Methods that create transactions throw an exception if a closing
operation is pending.

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

CreateObjectStore(string, IDBObjectStoreParameters)

The createObjectStore() method of the
IDBDatabase interface creates and returns a new IDBObjectStore.

[Value("createObjectStore")]
public IDBObjectStore CreateObjectStore(string name, IDBObjectStoreParameters options = null)

Parameters

name string
options IDBObjectStoreParameters

Returns

IDBObjectStore

A new IDBObjectStore.

Remarks

The method takes the name of the store as well as a parameter object that lets you
define important optional properties. You can use the property to uniquely identify
individual objects in the store. As the property is an identifier, it should be unique
to every object, and every object should have that property.

This method can be called only within a versionchange
transaction.

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

DeleteObjectStore(string)

The deleteObjectStore() method of the
IDBDatabase interface destroys the object store with the given name in
the connected database, along with any indexes that reference it.

[Value("deleteObjectStore")]
public GlobalObject.Undefined DeleteObjectStore(string name)

Parameters

name string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

As with CreateObjectStore(string, IDBObjectStoreParameters), this method can be called
only within a versionchange
transaction.

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Transaction(Union104, IDBTransactionMode, IDBTransactionOptions)

The transaction method of the IDBDatabase interface immediately returns a transaction object (IDBTransaction) containing the ObjectStore(string) method, which you can use to access your object store.

[Value("transaction")]
public IDBTransaction Transaction(Union104 storeNames, IDBTransactionMode mode = IDBTransactionMode.Readonly, IDBTransactionOptions options = null)

Parameters

storeNames Union104
mode IDBTransactionMode
options IDBTransactionOptions

Returns

IDBTransaction

An IDBTransaction object.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN