Ember.js 使用find()方法时,Route返回空模型

Ember.js 使用find()方法时,Route返回空模型,ember.js,ember-data,Ember.js,Ember Data,我有一个“时钟”记录,其中包含一些用户设置。记录保存在本地存储器中。如果页面被刷新,我不想在已经有记录的情况下一直创建新记录。 我正在使用余烬数据和LSAdapter 我的方法: 在ApplicationRoute中,我检查是否存在“clock”类型的记录 如果是-->将firstObject作为模型返回。 如果否-->创建新记录并返回它 总是创建一个新记录并将其返回的简单情况很好。这张唱片成了我的模特。但是,只要我使用this.find(),路由就会返回一个空模型 App.Applicatio

我有一个“时钟”记录,其中包含一些用户设置。记录保存在本地存储器中。如果页面被刷新,我不想在已经有记录的情况下一直创建新记录。
我正在使用余烬数据和LSAdapter

我的方法:
在ApplicationRoute中,我检查是否存在“clock”类型的记录

如果是-->将firstObject作为模型返回。
如果否-->创建新记录并返回它

总是创建一个新记录并将其返回的简单情况很好。这张唱片成了我的模特。但是,只要我使用this.find(),路由就会返回一个空模型

App.ApplicationRoute = Ember.Route.extend({

    model : function(){
        var length, clock;
        var self = this;

        this.store.find('clock').then(function(record){

            length = record.get("length");  // works

            if(length == 0){
                clock = self.store.createRecord('clock', {
                    soundOgg: "data/sounds/cling.ogg",
                    soundMp3: "data/sounds/cling.mp3"
                });
                console.log(clock); // prints correct object

                return clock;   // returns empty model

            } else {
                clock = record.get('firstObject');
                console.log(clock); // prints correct object

                return clock;   // returns empty model
            }    
        });    
    }
});
为什么它不起作用?是否有更好的方法返回正确的型号?

而不是此方法:

this.store.find('clock').then(...
这样做:

return this.store.find('clock').then(...
路由器的
模型
挂钩应该
返回
承诺