dojo/store/JsonRest (version 1.10)

dojo/store/api/Store

Summary

This is a basic store for RESTful communicating with a server through JSON formatted data. It implements dojo/store/api/Store.

Usage

var foo = new JsonRest(options);
dojo/store/JsonRest
Parameter Type Description
options dojo/store/JsonRest

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

See the dojo/store/JsonRest reference documentation for more information.

Property Summary

  • acceptsDefines the Accept header to use on HTTP requests
  • ascendingPrefixThe prefix to apply to sort attribute names that are ascending
  • descendingPrefixThe prefix to apply to sort attribute names that are ascending
  • headersAdditional headers to pass in all requests to the server.
  • idPropertyIndicates 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.
  • targetThe target base URL to use for all requests to the server.

Method Summary

  • _getTarget(id) If the target has no trailing '/', then append it.
  • add(object,options) Adds an object.
  • get(id,options) Retrieves an object by its identity.
  • getChildren(parent,options) Retrieves the children of an object.
  • getIdentity(object) Returns an object's identity
  • getMetadata(object) Returns any metadata about the object.
  • put(object,options) Stores an object.
  • query(query,options) Queries the store for objects.
  • remove(id,options) Deletes an object by its identity.
  • transaction() Starts a new transaction.

Properties

accepts
Defined by: dojo/store/JsonRest

Defines the Accept header to use on HTTP requests

ascendingPrefix
Defined by: dojo/store/JsonRest

The prefix to apply to sort attribute names that are ascending

descendingPrefix
Defined by: dojo/store/JsonRest

The prefix to apply to sort attribute names that are ascending

headers
Defined by: dojo/store/JsonRest

Additional headers to pass in all requests to the server. These can be overridden by passing additional headers to calls to the store.

idProperty
Defined by: dojo/store/JsonRest

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
target
Defined by: dojo/store/JsonRest

The target base URL to use for all requests to the server. This string will be prepended to the id to generate the URL (relative or absolute) for requests sent to the server

Methods

_getTarget(id)
Defined by dojo/store/JsonRest

If the target has no trailing '/', then append it.

Parameter Type Description
id Number

The identity of the requested target

Returns:string
add(object,options)
Defined by dojo/store/JsonRest

Adds an object. This will trigger a PUT request to the server if the object has an id, otherwise it will trigger a POST request.

Parameter Type Description
object Object

The object to store.

options Object
Optional

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

Returns:undefined
get(id,options)
Defined by dojo/store/JsonRest

Retrieves an object by its identity. This will trigger a GET request to the server using the url this.target + id.

Parameter Type Description
id Number

The identity to use to lookup the object

options Object
Optional

HTTP headers. For consistency with other methods, if a headers key exists on this object, it will be used to provide HTTP headers instead.

Returns:Object | undefined

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)
Defined by dojo/store/JsonRest

Returns an object's identity

Parameter Type Description
object Object

The object to get the identity from

Returns:Number | undefined
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,options)
Defined by dojo/store/JsonRest

Stores an object. This will trigger a PUT request to the server if the object has an id, otherwise it will trigger a POST request.

Parameter Type Description
object Object

The object to store.

options Object
Optional

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

Returns:dojo/_base/Deferred | undefined
query(query,options)
Defined by dojo/store/JsonRest

Queries the store for objects. This will trigger a GET request to the server, with the query added as a query string.

Parameter Type Description
query Object

The query to use for retrieving objects from the store.

options Object
Optional

The optional arguments to apply to the resultset.

The results of the query, extended with iterative methods.

remove(id,options)
Defined by dojo/store/JsonRest

Deletes an object by its identity. This will trigger a DELETE request to the server.

Parameter Type Description
id Number

The identity to use to delete the object

options Object
Optional

HTTP headers.

Returns:undefined
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.

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