-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ccd06a
commit 24cf523
Showing
9 changed files
with
29 additions
and
40 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
import DS from 'ember-data'; | ||
import { get } from '@ember/object'; | ||
|
||
export default DS.RESTAdapter.extend({ | ||
buildURL(modelName, id, snapshot) { | ||
let url = this._super(...arguments); | ||
let parentResource = get(snapshot, 'adapterOptions.parentResource') | ||
if (parentResource) { | ||
let { modelName: parentModelName } = parentResource.constructor; | ||
let parentAdapter = this.store.adapterFor(parentModelName); | ||
let parentUrl = parentAdapter.buildURL(parentModelName, parentResource.id); | ||
return `${parentUrl}${url}`; | ||
} | ||
return url; | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
content: DS.attr('string'), | ||
post: DS.belongsTo('post') | ||
content: DS.attr('string') | ||
}); |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
import DS from 'ember-data'; | ||
import DS from "ember-data"; | ||
import { set } from '@ember/object'; | ||
|
||
const { Store } = DS; | ||
|
||
export default DS.Store.extend({ | ||
findSubRecord(parentResource, resourceName, resourceId, options) { | ||
options = options || {}; | ||
options.adapterOptions = options.adapterOptions || {}; | ||
Object.assign(options.adapterOptions, { parentResource }); | ||
return this.findRecord(resourceName, resourceId, options); | ||
export default Store.extend({ | ||
findSubAll(parentResource, modelName, options = {}) { | ||
set(options, 'parentResource', parentResource); | ||
return this.findAll(modelName, options); | ||
}, | ||
findSubAll(parentResource, resourceName, options) { | ||
options = options || {}; | ||
options.adapterOptions = options.adapterOptions || {}; | ||
Object.assign(options.adapterOptions, { parentResource }); | ||
return this.findAll(resourceName, options); | ||
findSubRecord(parentResource, modelName, id, options = {}) { | ||
set(options, 'parentResource', parentResource); | ||
return this.findRecord(modelName, id, options); | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,11 @@ | |
"id": 1, | ||
"content": "some comment", | ||
"post_id": 1 | ||
}, | ||
{ | ||
"id": 2, | ||
"content": "some comment#", | ||
"post_id": 2 | ||
} | ||
] | ||
} |