dojo/data/ObjectStore (version 1.10)

dojo/Evented

Summary

A Dojo Data implementation that wraps Dojo object stores for backwards compatibility.

Usage

var foo = new ObjectStore(options);
dojo/data/ObjectStore
Parameter Type Description
options undefined

The configuration information to pass into the data store.

  • options.objectStore:

The object store to use as the source provider for this data store

See the dojo/data/ObjectStore reference documentation for more information.

Property Summary

Method Summary

  • changing(object,_deleting) adds an object to the list of dirty objects.
  • close(request) See dojo/data/api/Read.close()
  • 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.
  • emit(type,event)
  • fetch(args) See dojo/data/api/Read.fetch()
  • fetchItemByIdentity(args) fetch an item by its identity, by looking in our index of what we have loaded
  • getAttributes(item) Gets the available attributes of an item's 'property' and returns it as an array.
  • getFeatures() return the store feature set
  • getIdentity(item) returns the identity of the given item See dojo/data/api/Read.getIdentity()
  • getIdentityAttributes(item) returns the attributes which are used to make up the identity of an item.
  • getLabel(item) See dojo/data/api/Read.getLabel()
  • getLabelAttributes(item) See dojo/data/api/Read.getLabelAttributes()
  • 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 or true if there are any dirty items
  • isItem(item) Checks to see if the argument is an item
  • 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.
  • on(type,listener)
  • revert() returns any modified data to its original state prior to a save();
  • save(kwArgs) Saves the dirty data using object store provider.
  • setValue(item,attribute,value) sets 'attribute' on 'item' to 'value' See dojo/data/api/Write.setValue()
  • setValues(item,attribute,values) sets 'attribute' on 'item' to 'value' value must be an array.
  • unsetAttribute(item,attribute) unsets 'attribute' on 'item' See dojo/data/api/Write.unsetAttribute()

Event Summary

  • onDelete() See dojo/data/api/Notification.onDelete()
  • onFetch(results) Called when a fetch occurs
  • onNew() See dojo/data/api/Notification.onNew()
  • onSet() See dojo/data/api/Notification.onSet()

Properties

labelProperty
Defined by: dojo/data/ObjectStore
objectStore
Defined by: dojo/data/ObjectStore

Methods

changing(object,_deleting)

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

Parameter Type Description
object Object

Indicates that the given object is changing and should be marked as dirty for the next save

_deleting Boolean
close(request)

See dojo/data/api/Read.close()

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

The item to check

attribute String

The attribute to check

value Anything

The value to look for

Returns:boolean
deleteItem(item)

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

Parameter Type Description
item undefined

item to delete

emit(type,event)
Defined by dojo/Evented
Parameter Type Description
type undefined
event undefined
Returns:undefined
fetch(args)

See dojo/data/api/Read.fetch()

Parameter Type Description
args undefined
Returns:undefined
fetchItemByIdentity(args)

fetch an item by its identity, by looking in our index of what we have loaded

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
getFeatures()

return the store feature set

Returns:object
getIdentity(item)

returns the identity of the given item See dojo/data/api/Read.getIdentity()

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.objectStore.idProperty See dojo/data/api/Read.getIdentityAttributes()

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

See dojo/data/api/Read.getLabel()

Parameter Type Description
item dojo/data/api/Item
Returns:undefined
getLabelAttributes(item)

See dojo/data/api/Read.getLabelAttributes()

Parameter Type Description
item dojo/data/api/Item
Returns:Array
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:value

the default value

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

The item to check

attribute String

The attribute to check

Returns:boolean
isDirty(item)

returns true if the item is marked as dirty or true if there are any dirty items

Parameter Type Description
item Object

The item to check

Returns:boolean | undefined
isItem(item)

Checks to see if the argument is an item

Parameter Type Description
item Object

The item to check

Returns:boolean
isItemLoaded(item)

Checks to see if the item is loaded.

Parameter Type Description
item Object

The item to check

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 Object

See dojo/data/api/Read.fetch()

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

See dojo/data/api/Write.newItem()

parentInfo undefined
Returns:Object

See dojo/data/api/Write.newItem()

on(type,listener)
Defined by dojo/Evented
Parameter Type Description
type undefined
listener undefined
Returns:undefined
revert()

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

save(kwArgs)

Saves the dirty data using object store provider. See dojo/data/api/Write for API.

Parameter Type Description
kwArgs undefined
  • kwArgs.global: This will cause the save to commit the dirty data for all ObjectStores as a single transaction.

  • kwArgs.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.

  • kwArgs.onError: Called when an error occurs in the commit

  • kwArgs.onComplete: Called when an the save/commit is completed

setValue(item,attribute,value)

sets 'attribute' on 'item' to 'value' See dojo/data/api/Write.setValue()

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

sets 'attribute' on 'item' to 'value' value must be an array. See dojo/data/api/Write.setValues()

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

unsets 'attribute' on 'item' See dojo/data/api/Write.unsetAttribute()

Parameter Type Description
item undefined
attribute undefined

Events

onDelete()
Defined by: dojo/data/ObjectStore

Examples

Example 1

store.loadItem({
    item: item, // this item may or may not be loaded
    onItem: function(item){
        // do something with the item
    }
});
onFetch(results)
Defined by: dojo/data/ObjectStore

Called when a fetch occurs

Parameter Type Description
results undefined

Examples

Example 1

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

Examples

Example 1

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

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!