ObjectStore

extern class js.html.idb.ObjectStoreAvailable in jsThe IDBObjectStore interface of the IndexedDB API represents an object store in a database. Records within an object store are sorted according to their keys. This sorting enable fast insertion, look-up, and  ordered retrieval. 

Documentation for this class was provided by MDN.
var autoIncrement(default,null) : Bool var indexNames(default,null) : DOMStringListA list of the names of indexes on objects in this object store. var keyPath(default,null) : AnyThe key path of this object store. If this attribute is null, the application must provide a key for each modification operation. var name(default,null) : StringThe name of this object store. var transaction(default,null) : Transaction function add( value : Dynamic, ?key : Key ) : Request function clear() : Request function count( key : Key ) : Request

Immediately returns an IDBRequest object and asynchronously count the amount of objects in the object store that match the parameter, a key or a key range. If the parameter is not valid returns an exception.

Parameters
key
The key or key range that identifies the records to be counted.
Returns
IDBRequest
A request object on which subsequent events related to this operation are fired.
Exceptions

This method can raise an IDBDatabaseException with the following codes:

DATA_ERR
If the object store uses in-line keys or has a key generator, and a key parameter was provided.
If the object store uses out-of-line keys and has no key generator, and no key parameter was provided.
If the object store uses in-line keys but no key generator, and the object store's key path does not yield a valid key.
If the key parameter was provided but does not contain a valid key.
If there are indexed on this object store, and using their key path on the value parameter yields a value that is not a valid key.
NOT_ALLOWED_ERR
The request was made on a source object that has been deleted or removed.
Throws DatabaseException.
function createIndex( name : String, keyPath : String, ?options : Dynamic ) : Index

Creates and returns a new index in the connected database. Note that this method must be called only from a VERSION_CHANGE transaction callback.

IDBIndex createIndex (
  in DOMString name, 
  in DOMString keyPath, 
  in Object optionalParameters
) raises (IDBDatabaseException);

Parameters
name
The name of the index to create.
keyPath
The key path for the index to use.
optionalParameters
Warning: The latest draft of the specification changed this to IDBIndexParameters, which is not yet recognized by any browser

Options object whose attributes are optional parameters to the method. It includes the following properties:

Attribute Description
unique If true, the index will not allow duplicate values for a single key.
multientry If true, the index will add an entry in the index for each array element when the keypath resolves to an Array. If false, it will add one single entry containing the Array.

Unknown parameters are ignored.

Returns
IDBIndex
The newly created index.
Exceptions

This method can raise an IDBDatabaseException with the following codes:

CONSTRAINT_ERR
If an index with the same name (based on case-sensitive comparison) already exists in the connected database.
NOT_ALLOWED_ERR
If this method was not called from a VERSION_CHANGE transaction callback.
Throws DatabaseException.
function delete( key : Key ) : Request

Immediately returns an IDBRequest object, and removes the record specified by the given key from this object store, and any indexes that reference it, in a separate thread. If no record exists in this object store corresponding to the key, an error event is fired on the returned request object, with its code set to NOT_FOUND_ERR and an appropriate message. If the record is successfully removed, then a success event is fired on the returned request object, using the IDBTransactionEvent interface, with the result set to undefined, and transaction set to the transaction in which this object store is opened.

IDBRequest delete (
  in any key
) raises (IDBDatabaseException); 
Parameters
key
The key to use to identify the record.
Returns
IDBRequest
A request object on which subsequent events related to this operation are fired.
Exceptions

This method can raise an IDBDatabaseException with the following codes:

Throws DatabaseException.
function deleteIndex( name : String ) : Void function get( key : Key ) : Request

Immediately returns an IDBRequest object, and retrieves the requested record from the object store in a separate thread. If the operation is successful, then a success event is fired on the returned object, using the IDBTransactionEvent interface, with its result set to the retrieved value, and transaction set to the transaction in which this object store is opened. If a record does not exist in the object store for the key parameter, then an error event is fired on the returned object, with its code set to NOT_FOUND_ERR and an appropriate message.

Note: This function produces the same result if no record with the given key exists in the database as when a record exists, but with an undefined value. To tell these situations apart, call the openCursor() method with the same key. That method provides a cursor if the record exists, and not if it does not.
Parameters
key
The key identifying the record to retrieve.
Returns
IDBRequest
A request object on which subsequent events related to this operation are fired.
Exceptions

This method can raise an IDBDatabaseException with the following code:

DATA_ERR
If the key parameter was not a valid value.
TRANSACTION_INACTIVE_ERR
If the associated transaction is not active.
Throws DatabaseException.
function index( name : String ) : Index function openCursor( key : Key, ?direction : String ) : Request

Immediately returns an IDBRequest object, and creates a cursor over the records in this object store, in a separate thread. If there is even a single record that matches the key range, then a success event is fired on the returned object, with its result set to the IDBCursor object for the new cursor. If no records match the key range, then a success event is fired on the returned object, with its result set to null.

IDBRequest openCursor (
  in optional IDBKeyRange range, 
  in optional unsigned short direction
) raises (IDBDatabaseException);
Parameters
range
The key range to use as the cursor's range. If this parameter is unspecified or null, then the range includes all the records in the object store.
direction
The cursor's direction.
Returns
IDBRequest
A request object on which subsequent events related to this operation are fired.
Exceptions

This method can raise an IDBDatabaseException with the following code:

NOT_ALLOWED_ERR
If this object store is not in the scope of any existing transaction on the connected database.
Throws DatabaseException.
function put( value : Dynamic, ?key : Key ) : Request
version #18089, modified 2013-05-01 11:54:18 by api
0 comment