| Extends: | SC.Object |
| Defined in: | frameworks/sproutcore/models/store.js |
| Availability: | since SproutCore 1.0 |
The Store is where you can find all of your records. You should also use this to define your various types of records, since this will be used to automatically update from data coming from the server.
You should create a store for each application. This allows the records for apps to be kept separate, even if they live in the same page.
-
addRecord(rec)
-
findRecords()
-
getRecordFor(pkValue, recordType, dontAutoaddRecord)
-
records()
-
SC.Record
relocateRecord(oldkey, newkey, rec)
-
removeRecord(rec)
-
Array
updateRecords(dataHashes, dataSource, recordType, isLoaded)
Add a record instance to the store.
- addRecord (rec)
The record will now be monitored for changes.
You can pass any number of condition hashes to this, ending with a recordType.
- findRecords ()
It will AND the results of each condition hash.
finds the record with the primary key value.
- getRecordFor (pkValue, recordType, dontAutoaddRecord)
If the record does not exist, creates it.
Returns an array of all records in the store.
- records ()
Mostly used for storing.
Since records are cached by primaryKey, whenever that key changes we need to re-cache it in the proper place
- SC.Record relocateRecord (oldkey, newkey, rec)
SC.Record -
remove a record instance from the store.
- removeRecord (rec)
The record will no longer be monitored for changes and may be deleted.
Pushes updated data to all the named records.
- Array updateRecords (dataHashes, dataSource, recordType, isLoaded)
See discussion.
Usually a server object.
NO otherwise.
Array -
This method is often called from a server to update the store with the included record objects.
You can use this method yourself to mass update the store whenever you retrieve new records from the server. The first parameter should contain an array of JSON-compatible hashes. The hashes can have any properties you want but they should at least contain the following two keys: