dojo/store/api/Store (version 1.10)

Summary

This is an abstract API that data provider implementations conform to. This file defines methods signatures and intentionally leaves all the methods unimplemented. For more information on the , please visit: http://dojotoolkit.org/reference-guide/dojo/store.html Every method and property is optional, and is only needed if the functionality it provides is required. Every method may return a promise for the specified return value if the execution of the operation is asynchronous (except for query() which already defines an async return value).

Property Summary

  • idPropertyIf the store has a single primary key, this indicates the property to use as the identity property.
  • queryEngineIf the store can be queried locally (on the client side in JS), this defines the query engine to use for querying the data store.

Method Summary

Properties

idProperty
Defined by: dojo/store/api/Store

If the store has a single primary key, this indicates the property to use as the identity property. The values of this property should be unique.

queryEngine
Defined by: dojo/store/api/Store

If the store can be queried locally (on the client side in JS), this defines the query engine to use for querying the data store. This takes a query and query options and returns a function that can execute the provided query on a JavaScript array. The queryEngine may be replace to provide more sophisticated querying capabilities. For example:

var query = store.queryEngine({foo:"bar"}, {count:10});
query(someArray) -> filtered array

The returned query function may have a "matches" property that can be

used to determine if an object matches the query. For example:

query.matches({id:"some-object", foo:"bar"}) -> true
query.matches({id:"some-object", foo:"something else"}) -> false

Methods

add(object,directives)

Creates an object, throws an error if the object already exists

Parameter Type Description
object Object

The object to store.

directives dojo/store/api/Store.PutDirectives
Optional

Additional directives for creating objects.

Returns:Number|String
get(id)

Retrieves an object by its identity

Parameter Type Description
id Number

The identity to use to lookup the object

Returns:Object

The object in the store that matches the given id.

getChildren(parent,options)

Retrieves the children of an object.

Parameter Type Description
parent Object

The object to find the children of.

options dojo/store/api/Store.QueryOptions
Optional

Additional options to apply to the retrieval of the children.

A result set of the children of the parent object.

getIdentity(object)

Returns an object's identity

Parameter Type Description
object Object

The object to get the identity from

Returns:String|Number
getMetadata(object)

Returns any metadata about the object. This may include attribution, cache directives, history, or version information.

Parameter Type Description
object Object

The object to return metadata for.

Returns:Object

An object containing metadata.

put(object,directives)

Stores an object

Parameter Type Description
object Object

The object to store.

directives dojo/store/api/Store.PutDirectives
Optional

Additional directives for storing objects.

Returns:Number|String
PutDirectives()
query(query,options)

Queries the store for objects. This does not alter the store, but returns a set of data from the store.

Parameter Type Description
query String | Object | Function

The query to use for retrieving objects from the store.

options dojo/store/api/Store.QueryOptions

The optional arguments to apply to the resultset.

The results of the query, extended with iterative methods.

Examples

Example 1

Given the following store:

...find all items where "prime" is true:

store.query({ prime: true }).forEach(function(object){
    // handle each object
});
QueryOptions()
QueryResults()
remove(id)

Deletes an object by its identity

Parameter Type Description
id Number

The identity to use to delete the object

SortInformation()
transaction()

Starts a new transaction. Note that a store user might not call transaction() prior to using put, delete, etc. in which case these operations effectively could be thought of as "auto-commit" style actions.

This represents the new current transaction.

Transaction()
Error in the documentation? Can’t find what you are looking for? Let us know!