Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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