Ember Data Multiple Stores

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 14:50:10

问题


So I'm just starting to learn ember js. In the case of the application rest api I have namespaced models.

example: App.GlAccount = DS.Model.extend({})

the route I need it to follow is /gl/account

I thought I could fix this by creating another store like App.GlStore = DS.Store.create({adapter:DS.RestAdapter({namespace:'gl'})}

The problem is the model uses App.Store...Anyway to tell a model to use a different store?


回答1:


Based on your example it doesn't sounds like you actually need to have multiple data stores. The following should be all you need:

App.GlAccount = DS.Model.extend({});
App.GlAccount.reopenClass({
  url: 'gl/account'
});

If your needs are more complex, it is possible to have per-type adapters for your data store. See this gist for details: https://gist.github.com/4004913



来源:https://stackoverflow.com/questions/14236594/ember-data-multiple-stores

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!