dojox/store/db/IndexedDB (version 1.10)

Summary

This is a basic store for IndexedDB. It implements dojo/store/api/Store.

Usage

var foo = new IndexedDB(options);
dojox/store/db/IndexedDB
Parameter Type Description
options Object
Optional

This provides any configuration information that will be mixed into the store

Property Summary

  • idPropertyIndicates the property to use as the identity property.
  • indicesa hash of the preference of indices, indices that are likely to have very unique values should have the highest numbers as a reference, sorting is always set at 1, so properties that are higher than one will trigger filtering with index and then sort the whole set. we recommend setting boolean values at 0.1.
  • storeName

Method Summary

  • _callOnStore(method,args,index,returnRequest)
  • _getTransaction()
  • add(object,options) Adds an object.
  • get(id) Retrieves an object by its identity.
  • getIdentity(object) Returns an object's identity
  • put(object,options) Stores an object.
  • query(query,options) Queries the store for objects.
  • queryEngine(query,options) Simple query engine that matches using filter functions, named filter functions or objects by name-value on a query object hash
  • remove(id) Deletes an object by its identity.
  • transaction()

Properties

idProperty

Indicates the property to use as the identity property. The values of this property should be unique.

indices

a hash of the preference of indices, indices that are likely to have very unique values should have the highest numbers as a reference, sorting is always set at 1, so properties that are higher than one will trigger filtering with index and then sort the whole set. we recommend setting boolean values at 0.1.

storeName

Methods

_callOnStore(method,args,index,returnRequest)
Parameter Type Description
method undefined
args undefined
index undefined
returnRequest undefined
Returns:undefined
_getTransaction()
Returns:undefined
add(object,options)

Adds an object.

Parameter Type Description
object Object

The object to store.

options __PutDirectives
Optional

Additional metadata for storing the data. Includes an "id" property if a specific id is to be used.

Returns:dojo/Deferred | undefined
get(id)

Retrieves an object by its identity.

Parameter Type Description
id Number

The identity to use to lookup the object

Returns:dojo//Deferred | undefined
getIdentity(object)

Returns an object's identity

Parameter Type Description
object Object

The object to get the identity from

Returns:Number | undefined
put(object,options)

Stores an object.

Parameter Type Description
object Object

The object to store.

options __PutDirectives
Optional

Additional metadata for storing the data. Includes an "id" property if a specific id is to be used.

Returns:dojo/Deferred | undefined
query(query,options)

Queries the store for objects.

Parameter Type Description
query Object

The query to use for retrieving objects from the store.

options __QueryOptions
Optional

The optional arguments to apply to the resultset.

The results of the query, extended with iterative methods.

queryEngine(query,options)

Simple query engine that matches using filter functions, named filter functions or objects by name-value on a query object hash

The SimpleQueryEngine provides a way of getting a QueryResults through the use of a simple object hash as a filter. The hash will be used to match properties on data objects with the corresponding value given. In other words, only exact matches will be returned.

This function can be used as a template for more complex query engines; for example, an engine can be created that accepts an object hash that contains filtering functions, or a string that gets evaluated, etc.

When creating a new dojo.store, simply set the store's queryEngine field as a reference to this function.

Parameter Type Description
query Object

An object hash with fields that may match fields of items in the store. Values in the hash will be compared by normal == operator, but regular expressions or any object that provides a test() method are also supported and can be used to match strings by more complex expressions (and then the regex's or object's test() method will be used to match values).

options dojo/store/api/Store.QueryOptions
Optional

An object that contains optional information such as sort, start, and count.

Returns:Function | function

A function that caches the passed query under the field "matches". See any of the "query" methods on dojo.stores.

Examples

Example 1

Define a store with a reference to this engine, and set up a query method.

var myStore = function(options){
    //  ...more properties here
    this.queryEngine = SimpleQueryEngine;
    //  define our query method
    this.query = function(query, options){
        return QueryResults(this.queryEngine(query, options)(this.data));
    };
};
remove(id)

Deletes an object by its identity.

Parameter Type Description
id Number

The identity to use to delete the object

Returns:dojo/Deferred | undefined
transaction()
Returns:object
Error in the documentation? Can’t find what you are looking for? Let us know!