emberjs-force.find()在服务器上搜索新数据

emberjs force .find() to search for new data on server

本文关键字:新数据 数据 搜索 服务器 find emberjs-force      更新时间:2023-09-26

我的情况是打开一个渲染的{{each}},然后为一个新条目打开一个模态作为覆盖。使用.findAll(),当我用所需的.find()not保存新条目时,我的表会更新。。

我需要重新输入我的路线以获取新数据:

return this.store.find('user',{filter:{where: {role: 'abonnent'}}});

与我的api完美同步,但我不能附加参数:

return this.store.findAll('user');

我想这样使用它:

    import Ember from "ember";
    export default Ember.Route.extend({
      model:function(){
        return this.store.find('user',{filter:{where: {role: 'abonnent'}}});
        //return this.store.findAll('user');
      }
    });

如果需要"自动更新"过滤器,则应使用store.filterstore.allstore.filterstore.all是存储中的实时筛选器,而store.find则返回一个promise,解析服务器届时要回答的问题。

引用DS.Store#filter:的ED文档

获取一个类型和筛选器函数,并返回一个实时RecordArray在将新记录加载到存储或创建时保持最新本地。

以下是我如何写我的路线:

model: function() {
  return this.store.find('user', {
    filter: {where: {role: 'abonnent'}}
  });
},
setupController: function(controller, model) {
  this._super(controller, this.store.filter('user', function(record) {
    return record.get('role') === 'abonnent';
  }));
}