Created
December 9, 2011 17:39
-
-
Save workmanw/1452536 to your computer and use it in GitHub Desktop.
Datastore example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyApp = SC.Application.create({ | |
store: SC.Store.create() | |
}); | |
MyApp.MyRecord = SC.Record.extend(); | |
MyApp.resourcePath = "myRecord"; | |
// Load the record and save the storeKey | |
var storeKey = MyApp.store.loadRecord(MyApp.MyRecord, {}); | |
// Materialize a record instance | |
var recordInstance = MyApp.store.materializeRecord(storeKey); | |
// Determining which record we've got from the resourcePath property | |
var recordType = recordInstance.constructor.resourcePath; | |
// This would also work | |
recordType = MyApp.store.recordTypeFor(recordInstance.get('storeKey')).resourcePath; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment