Last active
August 29, 2015 14:01
-
-
Save awsp/87b60e5c1a87032d55e5 to your computer and use it in GitHub Desktop.
This file contains 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
MyApp.PhpDataSource = SC.DataSource.extend({ | |
queryQueries: function(query) { | |
var url, callback = ""; | |
if (query == MyApp.FIRST_QUERY) { | |
url = "/books"; | |
callback = "didFetchBooks"; | |
} | |
else if (query == MyApp.SECOND_QUERY) { | |
url = "/test"; | |
callback = "didFetchFoo"; | |
} | |
return { | |
url: url, | |
callback: callback, | |
}; | |
}, | |
fetch: function(store, query) { | |
var qd = this.queryQueries(query); | |
if (qd.url) { | |
SC.Request.getUrl(qd.url).header({ 'Accept': 'application/json' }).json() | |
.notify(this, qd.callback, store, query) | |
.send(); | |
return YES; | |
} | |
return NO; // return YES if you handled the query | |
}, | |
}); | |
MyApp.FIRST_QUERY = SC.Query.local(MyAppp.Book, { | |
conditions: "id = '1'" | |
}); | |
// In-memory? How do I execute to get `/books/1` to get Book where its id is 1? | |
var book = MyApp.store.find(MyApp.Book); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment