Last active
July 21, 2017 14:55
-
-
Save mikemunsie/49e787f556407ba040a256c8aab24b2c to your computer and use it in GitHub Desktop.
Creating a Custom Store in Ember
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 ApplicationAdapter from './application'; | |
export default ApplicationAdapter.extend({ | |
namespace: 'api/v1/admin' | |
}); |
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 'share/config/environment'; | |
const { | |
get, | |
inject, | |
} = Ember; | |
export default Route.extend({ | |
store: inject.service(), | |
adminStore: inject.service("stores/admin"), | |
init() { | |
// Will use the admin store with the admin adapter (api/v1/admin) | |
get(this, 'adminStore').findAll("user"); | |
// Will use the regular store (api/v1) | |
get(this, 'store').findAll("user"); | |
} | |
} |
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'; | |
const { | |
attr, | |
Store | |
} = DS; | |
export default Store.extend({ | |
adapterFor(modelName) { | |
return this._super("admin"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment