Skip to content

Instantly share code, notes, and snippets.

@pixelcort
Created June 12, 2009 22:15
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 pixelcort/128969 to your computer and use it in GitHub Desktop.
Save pixelcort/128969 to your computer and use it in GitHub Desktop.
App.Car = SC.Record.extend({
name: SC.Record.attr(String),
dealership: SC.Record.attr(App.Dealership),
// For some reason we need this computed property to make SC.Query work
dealershipGuid: function() {
return this.get('dealership').get('guid');
}.property('dealership').cacheable()
}) ;
App.Dealership = SC.Record.extend({
name: SC.Record.attr(String),
cars: function() {
var q;
q = SC.Query.create({
recordType: App.Cars,
conditions: "dealershipGuid = '" + this.get('guid') + "'"
});
return App.store.findAll(q);
}.property()
// memberships: SC.Record.toMany("App.Car", {
// inverse: 'dealership',
// isMaster: NO,
//
// })
// toMany fails so we have to build our own computed property
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment