Created
April 28, 2014 08:30
-
-
Save Geokoumpa/11365481 to your computer and use it in GitHub Desktop.
Ember-model findMany implementation
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
# this calls to a resource collection path adding an 'ids' param with comma separated ids, e.g. /posts?ids="1,2,3" | |
Ember.RESTAdapter.reopen findMany: (klass, records) -> | |
url = @buildURL(klass) | |
params = ids: records._ids.join(",") | |
@ajax(url, params).then (data) -> | |
collectionKey = Ember.get(klass, "collectionKey") | |
dataToLoad = (if collectionKey then Ember.get(data, collectionKey) else data) | |
Ember.run records, records.load, klass, dataToLoad | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment