Ember-data bootstrapping model objects

假装没事ソ 提交于 2019-12-24 00:27:08

问题


When bootstrapping Ember-data model objects with existing JSON that is not from a remote AJAX call, do I have to make the following 2 calls:

App.store.load(App.Account, data);
var account = App.store.find(App.Account, data.id);

Is it not possible to create the Object in one step, similar to calling setProperties on an existing Ember object?

Also, how would this work for creating a collection of Ember model objects? For example:

var users = App.get('users');
App.store.loadMany(App.User, users);
this.set('content', App.store.findMany(App.User, users.mapProperty('id').uniq()));

The above seems wrong. How can I create these objects from existing JSON objects?


回答1:


Seems ok to me, as store.load* returns something else than model objects (loaded ids & clientIds).

So far, I think there is no alternative.



来源:https://stackoverflow.com/questions/10887944/ember-data-bootstrapping-model-objects

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