ObjectStore

js.html.idb.ObjectStore (extern class)

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.)

Documentation IDBObjectStore by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See:

Instance Members

name: String

The name of this object store.


keyPath: Dynamic

The key path of this object store. If this attribute is null, the application must provide a key for each modification operation.


A list of the names of indexes on objects in this object store.


transaction: Transaction

The IDBTransaction object to which this object store belongs.


autoIncrement: Bool

The value of the auto increment flag for this object store.


put(value: Dynamic, ?key: Dynamic): Request

Returns an IDBRequest object, and, in a separate thread, creates a structured clone of the value, and stores the cloned value in the object store. This is for updating existing records in an object store when the transaction's mode is readwrite.

Name Type Default
value Dynamic
key Dynamic (optional)
Returns
Request

add(value: Dynamic, ?key: Dynamic): Request

Returns an IDBRequest object, and, in a separate thread, creates a structured clone of the value, and stores the cloned value in the object store. This is for adding new records to an object store.

Name Type Default
value Dynamic
key Dynamic (optional)
Returns
Request

delete(key: Dynamic): Request

returns an IDBRequest object, and, in a separate thread, deletes the store object selected by the specified key. This is for deleting individual records out of an object store.

Name Type
key Dynamic
Returns
Request

get(key: Dynamic): Request

Returns an IDBRequest object, and, in a separate thread, returns the store object store selected by the specified key. This is for retrieving specific records from an object store.

Name Type
key Dynamic
Returns
Request

getKey(key: Dynamic): Request

Returns an IDBRequest object, and, in a separate thread retrieves and returns the record key for the object in the object stored matching the specified parameter.

Name Type
key Dynamic
Returns
Request

clear(): Request

Creates and immediately returns an IDBRequest object, and clears this object store in a separate thread. This is for deleting all current records out of an object store.

Returns
Request

openCursor(?range: Dynamic, ?direction: CursorDirection = NEXT): Request

Returns an IDBRequest object, and, in a separate thread, returns a new IDBCursorWithValue object. Used for iterating through an object store by primary key with a cursor.

Name Type Default
range Dynamic (optional)
direction CursorDirection NEXT
Returns
Request

createIndex(name: String, keyPath: String, ?optionalParameters: Null<IndexParameters>): Index

Creates a new index during a version upgrade, returning a new IDBIndex object in the connected database.

Name Type Default
name String
keyPath String
optionalParameters Null<IndexParameters> (optional)
Returns
Index

index(name: String): Index

Opens an index from this object store after which it can, for example, be used to return a sequence of records sorted by that index using a cursor.

Name Type
name String
Returns
Index

deleteIndex(indexName: String): Void

Destroys the specified index in the connected database, used during a version upgrade.

Name Type
indexName String

count(?key: Dynamic): Request

Returns an IDBRequest object, and, in a separate thread, returns the total number of records that match the provided key or IDBKeyRange. If no arguments are provided, it returns the total number of records in the store.

Name Type Default
key Dynamic (optional)
Returns
Request

getAll(?key: Dynamic, ?limit: Int): Request

Returns an IDBRequest object retrieves all objects in the object store matching the specified parameter or all objects in the store if no parameters are given.

Name Type Default
key Dynamic (optional)
limit Int (optional)
Returns
Request

getAllKeys(?key: Dynamic, ?limit: Int): Request

Returns an IDBRequest object retrieves record keys for all objects in the object store matching the specified parameter or all objects in the store if no parameters are given.

Name Type Default
key Dynamic (optional)
limit Int (optional)
Returns
Request

openKeyCursor(?range: Dynamic, ?direction: CursorDirection = NEXT): Request

Returns an IDBRequest object, and, in a separate thread, returns a new IDBCursor. Used for iterating through an object store with a key.

Name Type Default
range Dynamic (optional)
direction CursorDirection NEXT
Returns
Request