Skip to content

Instantly share code, notes, and snippets.

@workmanw
Created December 9, 2011 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save workmanw/1452536 to your computer and use it in GitHub Desktop.
Save workmanw/1452536 to your computer and use it in GitHub Desktop.
Datastore example
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