问题描述
我不清楚以下两种查找方法之间的区别:
It is unclear to me what the difference is between the following 2 find methods:
model: function (params) {
return App.Publication.findById(params.publication_id);
},
model: function (params) {
return App.Publication.find(params.publication_id);
},
在transition.retry中使用findbyId方法时遇到问题;在这种情况下,模型没有加载,导致错误时转换...另请参见
I experienced problems when using the findbyId method in a transition.retry; in that case, the model did not load causing errors when transitioning ... See also Ember: route ID is lost after a transition.retry() - Am I doing something wrong?
推荐答案
我认为您正在谈论 DS.Store
,因为 DS.Model
没有
findById
方法。
I think that you are talking about the DS.Store
, because DS.Model
doesn't have a findById
method.
之间的差异,在商店中查找
和 findById
是findById,如名称所示:将通过ID找到数据。并找到一个多态的方法来查找您的参数记录:
The diference between, find
and findById
in store is that findById like the name says: will find the data by id. And find have a polymorphic way to find records based in your parameters:
- 调用store.find(App.Publication,1 / * number of string * /),将打开一个store.findById
- 使用store.find(App.Publication),将执行一个store.findAll
- 和store.find(App.Publication,{name:'Tom'}),调用store.findQuery
DS.Model.find有一个别名store.find,所以要做一个findById,只需调用App.Publication.find(1 / *数字的字符串* /)
DS.Model.find have a alias to store.find, so to make a findById, just call App.Publication.find(1 /* number of string */)
这篇关于Ember数据:find和findById有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!