Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC release] Update misleading example for Adapter.queryRecord() #3615

Merged
merged 1 commit into from
Aug 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions packages/ember-data/lib/system/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,16 @@ var Adapter = Ember.Object.extend({

Example

```javascript
App.ApplicationAdapter = DS.Adapter.extend({
queryRecord: function(store, typeClass, query) {
var url = [type.typeKey, id].join('/');
```app/adapters/application.js
import DS from 'ember-data';
import Ember from 'ember';

export default DS.Adapter.extend(DS.BuildURLMixin, {
queryRecord: function(store, type, query) {
var urlForQueryRecord = this.buildURL(type.modelName, null, null, 'queryRecord', query);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the record I didn't mean to change the variable name but to call urlForQueryRecord instead of buildURL :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄


return new Ember.RSVP.Promise(function(resolve, reject) {
Ember.$.getJSON(url, query).then(function(data) {
Ember.$.getJSON(urlForQueryRecord, query).then(function(data) {
Ember.run(null, resolve, data);
}, function(jqXHR) {
jqXHR.then = null; // tame jQuery's ill mannered promises
Expand All @@ -220,7 +223,6 @@ var Adapter = Ember.Object.extend({
@param {DS.Store} store
@param {subclass of DS.Model} type
@param {Object} query
@param {String} id
@return {Promise} promise
*/
queryRecord: null,
Expand Down