Interface

IDBObjectStore

IDBObjectStore

This example shows a variety of different uses of object stores, from updating the data structure with IDBObjectStore.createIndex inside an onupgradeneeded function, to adding a new item to our object store with IDBObjectStore.add. For a full working example, see our To-do Notifications app (view example live.)

View Source js/lib.dom.d.ts, line 4482

Members

IDBRequest.<IDBValidKey>

# add

Adds or updates a record in store with the given value and key.

If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown.

If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException.

If successful, request's result will be the record's key.

View Source js/lib.dom.d.ts, line 4510

boolean

# autoIncrement

Returns true if the store has a key generator, and false otherwise.

View Source js/lib.dom.d.ts, line 4485

IDBRequest.<undefined>

# clear

Deletes all records in store.

If successful, request's result will be undefined.

View Source js/lib.dom.d.ts, line 4521

IDBRequest.<number>

# count

Retrieves the number of records matching the given key or key range in query.

If successful, request's result will be the count.

View Source js/lib.dom.d.ts, line 4528

IDBIndex

# createIndex

Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException.

Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.

View Source js/lib.dom.d.ts, line 4535

IDBRequest.<undefined>

# delete

Deletes records in store with the given key or in the given key range in query.

If successful, request's result will be undefined.

View Source js/lib.dom.d.ts, line 4542

void

# deleteIndex

Deletes the index in store with the given name.

Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.

View Source js/lib.dom.d.ts, line 4549

IDBRequest.<(any|undefined)>

# get

Retrieves the value of the first record matching the given key or key range in query.

If successful, request's result will be the value, or undefined if there was no matching record.

View Source js/lib.dom.d.ts, line 4556

IDBRequest.<Array>

# getAll

Retrieves the values of the records matching the given key or key range in query (up to count if given).

If successful, request's result will be an Array of the values.

View Source js/lib.dom.d.ts, line 4563

IDBRequest.<Array>

# getAllKeys

Retrieves the keys of records matching the given key or key range in query (up to count if given).

If successful, request's result will be an Array of the keys.

View Source js/lib.dom.d.ts, line 4570

IDBRequest.<(IDBValidKey|undefined)>

# getKey

Retrieves the key of the first record matching the given key or key range in query.

If successful, request's result will be the key, or undefined if there was no matching record.

View Source js/lib.dom.d.ts, line 4577

DOMStringList

# indexNames

Returns a list of the names of indexes in the store.

View Source js/lib.dom.d.ts, line 4490

string | Array

# keyPath

Returns the key path of the store, or null if none.

View Source js/lib.dom.d.ts, line 4495

string

# name

Returns the name of the store.

View Source js/lib.dom.d.ts, line 4500

IDBRequest.<(IDBCursorWithValue|null)>

# openCursor

Opens a cursor over the records matching query, ordered by direction. If query is null, all records in store are matched.

If successful, request's result will be an IDBCursorWithValue pointing at the first matching record, or null if there were no matching records.

View Source js/lib.dom.d.ts, line 4584

IDBRequest.<(IDBCursor|null)>

# openKeyCursor

Opens a cursor with key only flag set over the records matching query, ordered by direction. If query is null, all records in store are matched.

If successful, request's result will be an IDBCursor pointing at the first matching record, or null if there were no matching records.

View Source js/lib.dom.d.ts, line 4591

IDBRequest.<IDBValidKey>

# put

Adds or updates a record in store with the given value and key.

If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown.

If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException.

If successful, request's result will be the record's key.

View Source js/lib.dom.d.ts, line 4598

IDBTransaction

# transaction

Returns the associated transaction.

View Source js/lib.dom.d.ts, line 4505