I am trying to use multiple stores in Ember because I have namespaced models on the api side.
Aka
App.Gl.Account = DS.Model.extend //Needs to route to /gl/accounts
App.Company = DS.Model.extend //Routes to /companies
My first thought was to define a namespace
App.Gl = Ember.Namespace.create({});
//and a store
App.Gl.Store = DS.Store.extend({adapter:DS.RESTAdapter({namespace:'gl'})});
App.Store = DS.Store.extend({adapter:DS.RESTAdapter})
problem is the model is automatically binded to the App.Store.
Any other suggestions on how to accomplish namespaced models would be helpful. I dont even need them namespaced on the client js side, as long as there is an easy way to specify the namespace for each individual model
The store contains all of the data for records loaded from the server. It is also responsible for creating instances of Model that wrap the individual data for a record, so that they can be bound to in your Handlebars templates.
Ember. js is a JavaScript framework for creating ambitious web applications.
You should never have more than one store in an Ember application.
Instead, you can register adapters for specific types:
App.Store.registerAdapter('App.Post', DS.RESTAdapter.extend({
// implement adapter; in this case
url: "/gl"
}));
You will probably want to use the RESTAdapter
as a starting point, unless you have specific needs and are willing to get down and dirty with the (still evolving) adapter API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With