dojox/data/S3Store (version 1.10)

dojox/data/JsonRestStore

Summary

S3JsonRestStore is an extension of JsonRestStore to handle Amazon's S3 service using JSON data

Usage

var foo = new S3Store(options);
dojox/data/JsonRestStore
<

The JsonRestStore will cause all saved modifications to be sent to the server using Rest commands (PUT, POST, or DELETE). When using a Rest store on a public network, it is important to implement proper security measures to control access to resources.

On the server side implementing a REST interface means providing GET, PUT, POST, and DELETE handlers.

These articles include more detailed information on using the JsonRestStore:

>The JsonRestStore will cause all saved modifications to be sent to the server using Rest commands (PUT, POST, or DELETE). When using a Rest store on a public network, it is important to implement proper security measures to control access to resources.

On the server side implementing a REST interface means providing GET, PUT, POST, and DELETE handlers.

These articles include more detailed information on using the JsonRestStore:

>
Parameter Type Description
options undefined

Keyword arguments

The schema parameter

This is a schema object for this store. This should be JSON Schema format.

The service parameter

This is the service object that is used to retrieve lazy data and save results The function should be directly callable with a single parameter of an object id to be loaded The function should also have the following methods:

  • put(id,value) - puts the value at the given id
  • post(id,value) - posts (appends) the value at the given id
  • delete(id) - deletes the value corresponding to the given id

Note that it is critical that the service parses responses as JSON. If you are using dojox.rpc.Service, the easiest way to make sure this happens is to make the responses have a content type of application/json. If you are creating your own service, make sure you use handleAs: "json" with your XHR requests.

The target parameter

This is the target URL for this Service store. This may be used in place of a service parameter to connect directly to RESTful URL without using a dojox.rpc.Service object.

The idAttribute parameter

Defaults to 'id'. The name of the attribute that holds an objects id. This can be a preexisting id provided by the server. If an ID isn't already provided when an object is fetched or added to the store, the autoIdentity system will generate an id for it and add it to the index.

The syncMode parameter

Setting this to true will set the store to using synchronous calls by default. Sync calls return their data immediately from the calling function, so callbacks are unnecessary

See the dojox/data/S3Store reference documentation for more information.

Property Summary

Method Summary

  • _doQuery(args)
  • _processResults(results)
  • cancelChanging(object) Removes an object from the list of dirty objects This will prevent that object from being saved to the server on the next save
  • changing(item,_deleting) adds an item to the list of dirty items.
  • close(request)
  • containsValue(item,attribute,value) Checks to see if 'item' has 'value' at 'attribute'
  • deleteItem(item) deletes item and any references to that item from the store.
  • fetch(args) See dojo/data/api/Read.fetch
  • fetchItemByIdentity(args)
  • getAttributes(item) Gets the available attributes of an item's 'property' and returns it as an array.
  • getConstructor() Gets the constructor for objects from this store
  • getFeatures() return the store feature set
  • getIdentity(item)
  • getIdentityAttributes(item) returns the attributes which are used to make up the identity of an item.
  • getLabel(item) returns the label for an item.
  • getLabelAttributes(item) returns an array of attributes that are used to create the label of an item
  • getParent(item) Returns the parent item (or query) for the given item
  • getSchema() Returns a reference to the JSON Schema
  • getValue(item,property,defaultValue) Gets the value of an item's 'property'
  • getValues(item,property) Gets the value of an item's 'property' and returns it.
  • hasAttribute(item,attribute) Checks to see if item has attribute
  • isDirty(item) returns true if the item is marked as dirty.
  • isItem(item,anyStore) Checks to see if a passed 'item' really belongs to this JsonRestStore.
  • isItemLoaded(item) Checks to see if the item is loaded.
  • loadItem(args) Loads an item and calls the callback handler.
  • newItem(data,parentInfo) adds a new item to the store at the specified point.
  • revert(kwArgs) returns any modified data to its original state prior to a save();
  • save(kwArgs) Saves the dirty data using REST Ajax methods.
  • setValue(item,attribute,value) sets 'attribute' on 'item' to 'value'
  • setValues(item,attribute,values) sets 'attribute' on 'item' to 'value' value must be an array.
  • unsetAttribute(item,attribute) unsets 'attribute' on 'item'

Event Summary

Properties

_currentId
allowNoTrailingSlash

Allow no trailing slash on target paths. This is generally discouraged since it creates prevents simple scalar values from being used a relative URLs. Disabled by default.

estimateCountFactor

This parameter is used by the ServiceStore to estimate the total count. When paging is indicated in a fetch and the response includes the full number of items requested by the fetch's count parameter, then the total count will be estimated to be estimateCountFactor multiplied by the provided count. If this is 1, then it is assumed that the server does not support paging, and the response is the full set of items, where the total count is equal to the numer of items returned. If the server does support paging, an estimateCountFactor of 2 is a good value for estimating the total count It is also possible to override _processResults if the server can provide an exact total count.

idAsRef

Treat objects in queries as partially loaded objects

idAttribute

Defaults to 'id'. The name of the attribute that holds an objects id. This can be a preexisting id provided by the server. If an ID isn't already provided when an object is fetched or added to the store, the autoIdentity system will generate an id for it and add it to the index.

labelAttribute
loadLazyValues
loadReferencedSchema

Will load any schemas referenced content-type header or in Link headers

referenceIntegrity
schema

This is a schema object for this store. This should be JSON Schema format.

service

This is the service object that is used to retrieve lazy data and save results The function should be directly callable with a single parameter of an object id to be loaded

syncMode

Setting this to true will set the store to using synchronous calls by default. Sync calls return their data immediately from the calling function, so callbacks are unnecessary. This will only work with a synchronous capable service.

target

Methods

_doQuery(args)
Parameter Type Description
args undefined
Returns:undefined
_processResults(results)
Defined by dojox/data/S3Store
Parameter Type Description
results undefined
Returns:object
cancelChanging(object)

Removes an object from the list of dirty objects This will prevent that object from being saved to the server on the next save

Parameter Type Description
object undefined

The item to cancel changes on

changing(item,_deleting)

adds an item to the list of dirty items. This item contains a reference to the item itself as well as a cloned and trimmed version of old item for use with revert.

Parameter Type Description
item undefined
_deleting undefined
close(request)
Parameter Type Description
request undefined
Returns:undefined
containsValue(item,attribute,value)

Checks to see if 'item' has 'value' at 'attribute'

Parameter Type Description
item Object
attribute String
value Anything
Returns:boolean
deleteItem(item)

deletes item and any references to that item from the store.

Parameter Type Description
item undefined

item to delete

fetch(args)

See dojo/data/api/Read.fetch

Parameter Type Description
args undefined

The queryOptions.cache parameter

If true, indicates that the query result should be cached for future use. This is only available if dojox.data.ClientFilter has been loaded before the ServiceStore

The syncMode parameter

Indicates that the call should be fetch synchronously if possible (this is not always possible)

The clientFetch parameter

This is a fetch keyword argument for explicitly doing client side filtering, querying, and paging

Returns:string
fetchItemByIdentity(args)
Parameter Type Description
args undefined
Returns:undefined
getAttributes(item)

Gets the available attributes of an item's 'property' and returns it as an array.

Parameter Type Description
item Object
Returns:Array
getConstructor()

Gets the constructor for objects from this store

Returns:undefined
getFeatures()

return the store feature set

Returns:undefined
getIdentity(item)
Parameter Type Description
item undefined
Returns:undefined
getIdentityAttributes(item)

returns the attributes which are used to make up the identity of an item. Basically returns this.idAttribute

Parameter Type Description
item undefined
Returns:Array
getLabel(item)

returns the label for an item. Just gets the "label" attribute.

Parameter Type Description
item undefined
Returns:undefined
getLabelAttributes(item)

returns an array of attributes that are used to create the label of an item

Parameter Type Description
item undefined
Returns:Array
getParent(item)

Returns the parent item (or query) for the given item

Parameter Type Description
item undefined

The item to find the parent of

Returns:undefined
getSchema()

Returns a reference to the JSON Schema

Returns:Object | undefined
getValue(item,property,defaultValue)

Gets the value of an item's 'property'

Parameter Type Description
item Object

The item to get the value from

property String

property to look up value for

defaultValue value
Optional

the default value

Returns:return the plain value since it was found;
getValues(item,property)

Gets the value of an item's 'property' and returns it. If this value is an array it is just returned, if not, the value is added to an array and that is returned.

Parameter Type Description
item Object
property String

property to look up value for

Returns:Array
hasAttribute(item,attribute)

Checks to see if item has attribute

Parameter Type Description
item Object
attribute String
Returns:boolean
isDirty(item)

returns true if the item is marked as dirty.

Parameter Type Description
item undefined
Returns:undefined
isItem(item,anyStore)

Checks to see if a passed 'item' really belongs to this JsonRestStore.

Parameter Type Description
item Object

The value to test for being an item

anyStore Boolean

If true, this will return true if the value is an item for any JsonRestStore, not just this instance

Returns:undefined
isItemLoaded(item)

Checks to see if the item is loaded.

Parameter Type Description
item object
Returns:undefined
loadItem(args)

Loads an item and calls the callback handler. Note, that this will call the callback handler even if the item is loaded. Consequently, you can use loadItem to ensure that an item is loaded is situations when the item may or may not be loaded yet. If you access a value directly through property access, you can use this to load a lazy value as well (doesn't need to be an item).

Parameter Type Description
args undefined
Returns:undefined

Examples

Example 1

store.loadItem({
    item: item, // this item may or may not be loaded
    onItem: function(item){
        // do something with the item
    }
});
newItem(data,parentInfo)

adds a new item to the store at the specified point. Takes two parameters, data, and options.

Parameter Type Description
data Object

The data to be added in as an item.

parentInfo undefined
Returns:instance
revert(kwArgs)

returns any modified data to its original state prior to a save();

Parameter Type Description
kwArgs undefined
  • global: This will cause the revert to undo all the changes for all JsonRestStores in a single operation.
save(kwArgs)

Saves the dirty data using REST Ajax methods. See dojo/data/api/Write for API.

Parameter Type Description
kwArgs undefined
  • global: This will cause the save to commit the dirty data for all JsonRestStores as a single transaction.
  • revertOnError: This will cause the changes to be reverted if there is an error on the save. By default a revert is executed unless a value of false is provide for this parameter.
  • incrementalUpdates: For items that have been updated, if this is enabled, the server will be sent a POST request with a JSON object containing the changed properties. By default this is not enabled, and a PUT is used to deliver an update, and will include a full serialization of all the properties of the item/object. If this is true, the POST request body will consist of a JSON object with only the changed properties. The incrementalUpdates parameter may also be a function, in which case it will be called with the updated and previous objects and an object update representation can be returned.
  • alwaysPostNewItems: If this is true, new items will always be sent with a POST request. By default this is not enabled, and the JsonRestStore will send a POST request if the item does not include its identifier (expecting server assigned location/ identifier), and will send a PUT request if the item does include its identifier (the PUT will be sent to the URI corresponding to the provided identifier).
Returns:undefined
setValue(item,attribute,value)

sets 'attribute' on 'item' to 'value'

Parameter Type Description
item undefined
attribute undefined
value undefined
setValues(item,attribute,values)

sets 'attribute' on 'item' to 'value' value must be an array.

Parameter Type Description
item undefined
attribute undefined
values undefined
unsetAttribute(item,attribute)

unsets 'attribute' on 'item'

Parameter Type Description
item undefined
attribute undefined

Events

onDelete()

Examples

Example 1

store.loadItem({
    item: item, // this item may or may not be loaded
    onItem: function(item){
        // do something with the item
    }
});
onNew()

Examples

Example 1

store.loadItem({
    item: item, // this item may or may not be loaded
    onItem: function(item){
        // do something with the item
    }
});
onSet()

Examples

Example 1

store.loadItem({
    item: item, // this item may or may not be loaded
    onItem: function(item){
        // do something with the item
    }
});
Error in the documentation? Can’t find what you are looking for? Let us know!