class ObjectStore
package js.html.idb
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 also:
Variables
Methods
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.
Throws:
null | DOMError |
---|
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.
Throws:
null | DOMError |
---|
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.
Throws:
null | DOMError |
---|
createIndex(name:String, keyPath:String, ?optionalParameters:Null<IndexParameters>):Index
createIndex(name:String, keyPath:Array<String>, ?optionalParameters:Null<IndexParameters>):Index
Creates a new index during a version upgrade, returning a new IDBIndex
object in the connected database.
Throws:
null | DOMError |
---|
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.
Throws:
null | DOMError |
---|
deleteIndex(indexName:String):Void
Destroys the specified index in the connected database, used during a version upgrade.
Throws:
null | DOMError |
---|
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.
Throws:
null | DOMError |
---|
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.
Throws:
null | DOMError |
---|
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.
Throws:
null | DOMError |
---|
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.
Throws:
null | DOMError |
---|
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.
Throws:
null | DOMError |
---|
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.
Throws:
null | DOMError |
---|
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.
Throws:
null | DOMError |
---|
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
.
Throws:
null | DOMError |
---|