-
-
Save ehynds/849218 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//////////////// | |
// IN CONSOLE // | |
//////////////// | |
Blah = Model("blah", { | |
persistence: Model.localStorage(), | |
find_by_uid: function(uid) { | |
return this.detect(function() { | |
return this.uid == uid | |
}) | |
} | |
}) | |
blah = new Blah({ name: "Blah" }) | |
blah.uid | |
// => "blah-1298988849274-662" | |
blah.save() | |
Blah.all() | |
// => [blah] | |
////////////////// | |
// REFRESH PAGE // | |
////////////////// | |
Blah = Model("blah", { | |
persistence: Model.localStorage(), | |
find_by_uid: function(uid) { | |
return this.detect(function() { | |
return this.uid == uid | |
}) | |
} | |
}) | |
Blah.all() | |
// => [] | |
Blah.load() | |
Blah.all() | |
// => [blah] | |
// Use the uid returned earlier. | |
Blah.find_by_uid("blah-1298988849274-662") | |
// => blah |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment