Created
June 27, 2016 19:10
-
-
Save Kilowhisky/8058c9349db3e850115b6186ee1ae61e to your computer and use it in GitHub Desktop.
Query Record Relationships Error
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
import DS from 'ember-data'; | |
export default DS.RESTAdapter.extend({}); |
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
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
myset: belongsTo('myset'), | |
createdDate: attr('date'), | |
settings: attr() | |
}); |
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
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
name: attr('string'), | |
revisionLatest: belongsTo('myset-revision') | |
}); |
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
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('set-edit', { path: '/edit/:set_id/:revision_id' }); | |
}); | |
export default Router; |
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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
init(){ | |
this._super(...arguments); | |
$.mockjax({ | |
url: '/mysets', | |
responseText: [ | |
{ | |
id: "1", | |
name: "Test 1", | |
revisionLatest: "2" | |
} | |
] | |
}); | |
$.mockjax({ | |
url: '/mysets/1', | |
responseText: { | |
id: "1", | |
name: "Test 1", | |
revisionLatest: "2" | |
} | |
}); | |
$.mockjax({ | |
url: '/mysetRevisions/2', | |
responseText: { | |
id: "2", | |
myset: "1", | |
createdDate: "2016-06-27T16:11:43.4970000Z" | |
} | |
}); | |
$.mockjax({ | |
url: '/mysetRevisions', | |
data: { | |
includeSettings: true, | |
revision: 2 | |
}, | |
responseText: { | |
id: "2", | |
myset: "1", | |
createdDate: "2016-06-27T16:11:43.4970000Z", | |
settings: { | |
setting1: "value" | |
} | |
} | |
}); | |
$.mockjax({ | |
url: '/mysetRevisions', | |
data: { | |
includeSettings: true, | |
revision: 1 | |
}, | |
responseText: { | |
id: "1", | |
myset: "1", | |
createdDate: "2016-06-27T16:11:43.4970000Z", | |
settings: { | |
setting1: "value1" | |
} | |
} | |
}); | |
$.mockjax({ | |
url: '/mysetRevisions', | |
data: { | |
setId: 1 | |
}, | |
responseText: [ | |
{ id: "1", myset: "1", createdDate: "2016-06-27T15:11:43.4970000Z" }, | |
{ id: "2", myset: "1", createdDate: "2016-06-27T16:11:43.4970000Z" } | |
] | |
}); | |
}, | |
model(){ | |
return this.store.findAll('myset') | |
} | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model(params){ | |
return Ember.RSVP.hash({ | |
set: this.store.findRecord('myset', params.set_id), | |
revision: this.store.queryRecord('myset-revision', { | |
revision: params.revision_id, | |
includeSettings: true | |
}), | |
revisions: this.store.query('myset-revision', { setId: params.set_id }) | |
}); | |
} | |
}); |
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
import DS from 'ember-data'; | |
export default DS.JSONSerializer.extend({}); |
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
{ | |
"version": "0.10.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.6.0", | |
"ember-data": "2.6.1", | |
"ember-template-compiler": "2.6.0", | |
"jquery-mockjax": "https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.6.2/jquery.mockjax.js" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment