Class: SC.NestedStore


Extends SC.Store.

A nested store can buffer changes to a parent store and then commit them all at once. You usually will use a NestedStore as part of store chaining to stage changes to your object graph before sharing them with the rest of the application.

Normally you will not create a nested store directly. Instead, you can retrieve a nested store by using the chain() method. When you are finished working with the nested store, destroy() will dispose of it.

Defined in: nested_store.js

Since:
SproutCore 1.0

Field Summary

Instance Methods

Field Detail

Read Only
conflictedStoreKeys Array

An array of store keys for all conflicting records with the parent store. If there are no conflicting records, this property will be null.

Default value:
null
hasChanges Boolean

This is set to YES when there are changes that have not been committed yet.

Default value:
NO
isNested Boolean
`YES` if the store is nested. Walk like a duck
Default value:
YES
lockOnRead Boolean

If YES, then the attribute hash state will be locked when you first read the data hash or status. This means that if you retrieve a record then change the record in the parent store, the changes will not be visible to your nested store until you commit or discard changes.

If NO, then the attribute hash will lock only when you write data.

Normally you want to lock your attribute hash the first time you read it. This will make your nested store behave most consistently. However, if you are using multiple sibling nested stores at one time, you may want to turn off this property so that changes from one store will be reflected in the other one immediately. In this case you will be responsible for ensuring that the sibling stores do not edit the same part of the object graph at the same time.

Default value:
YES
parentStore SC.Store

The parent store this nested store is chained to. Nested stores must have a parent store in order to function properly. Normally, you create a nested store using the SC.Store#chain() method and this property will be set for you.

Default value:
null

Instance Method Detail

commitChanges(force)

Propagate this store's changes to its parent. If the store does not have a parent, this has no effect other than to clear the change set.

Parameters:
force Boolean
if YES, does not check for conflicts first
Returns:
SC.Store
receiver
commitSuccessfulChanges(force)

Propagate this store's successful changes to its parent (if exists). At the end, it clears the local, private status of the committed records therefore the method can be called several times until the full transaction is successful or editing is abandoned

Parameters:
force Boolean
if YES, does not check for conflicts first
Returns:
SC.Store
receiver
destroy()

When you are finished working with a chained store, call this method to tear it down. This will also discard any pending changes.

Returns:
SC.Store
receiver
discardChanges()
Discard the changes made to this store and reset the store.
Returns:
SC.Store
receiver
find(query)

find() cannot accept REMOTE queries in a nested store. This override will verify that condition for you. See SC.Store#find() for info on using this method.

Parameters:
query SC.Query
query object to use.
Returns:
SC.Record|SC.RecordArray
readError(storeKey)

Returns the SC.Error object associated with a specific record.

Delegates the call to the parent store.

Parameters:
storeKey Number
The store key of the record.
Returns:
SC.Error
SC.Error or null if no error associated with the record.
readQueryError(query)

Returns the SC.Error object associated with a specific query.

Delegates the call to the parent store.

Parameters:
query SC.Query
The SC.Query with which the error is associated.
Returns:
SC.Error
SC.Error or null if no error associated with the query.
reset()
Resets a store's data hash contents to match its parent.
storeKeyEditState(storeKey)

Returns the current edit status of a storekey. May be one of INHERITED, EDITABLE, and LOCKED. Used mostly for unit testing.

Parameters:
storeKey Number
the store key
Returns:
Number
edit status
Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 08 2015 10:02:21 GMT-0600 (CST)