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
- Fields borrowed from SC.Store:
- CHAIN_CONFLICT_ERROR, changelog, childRecords, commitRecordsAutomatically, dataSource, EDITABLE, editables, INHERITED, LOCKED, name, NESTED_STORE_RETRIEVE_DIRTY_ERROR, NESTED_STORE_UNSUPPORTED_ERROR, nestedStores, NO_PARENT_STORE_ERROR, parentRecords, queryErrors, recordErrors
- Fields borrowed from SC.Object:
- concatenatedProperties, isDestroyed, isObject, nextProperty, object, property, target, toInvalidate
- Fields borrowed from SC.Observable:
- isObservable
Instance Methods
- commitChanges(force)
- commitSuccessfulChanges(force)
- destroy()
- discardChanges()
- find(query)
- readError(storeKey)
- readQueryError(query)
- reset()
- storeKeyEditState(storeKey)
Field Detail
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
This is set to YES
when there are changes that have not been committed
yet.
- Default value:
- NO
- Default value:
- YES
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
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
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.
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
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
- Returns:
- SC.Store
- receiver
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
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.
Returns the SC.Error
object associated with a specific query.
Delegates the call to the parent store.
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