Skip to content

Instantly share code, notes, and snippets.

@topherfangio
Created April 18, 2011 17:05
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 topherfangio/925708 to your computer and use it in GitHub Desktop.
Save topherfangio/925708 to your computer and use it in GitHub Desktop.
You can also find all records of a certain type and all its subclasses:
<javascript>
allRecords = MyApp.store.find(SC.Record);
</javascript>
@topherfangio
Copy link
Author

This doesn't make a lot of sense to me. This leaves off the "records of a certain type". Can someone correct this please? I haven't used this feature of SC yet.

@tim-evans
Copy link

allRecords = MyApp.store.find(SC.Record); // Every record in the store (this will materialize them all- beware!)
fileRecords = MyApp.store.find(MyApp.File); // Returns all MyApp.File records

@tim-evans
Copy link

If you would like to get all records of a certain type and all it's subclasses, you need to do:

MyApp.File = MyApp.Blob.extend();
MyApp.Directory = MyApp.Blob.extend();
result = MyApp.store.find(SC.Query.local(MyApp.Blob)); // Returns all MyApp.Blob, MyApp.File, and MyApp.Directory records

allBlobs = MyApp.store.find(MyApp.Blob); // Returns _only_ MyApp.Blob

MyApp.Blob.isPolymorphic = YES; // with the new polymorphic framework!

allBlobTypedRecords = MyApp.store.find(MyApp.Blob); // same as record query!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment