Geekingfrog
Geekingfrog

Reputation: 191

Ember.js data - basic adapter does not implement findAll method?

With the basic adapter

App.Store = DS.Store.extend({
    revision: 12,
    adapter: 'DS.BasicAdapter'
});

I have:

'Uncaught Adapter is either null or does not implement findAll method'.

And indeed there is no findAll method in the basicAdapter (I did make sure the adapter isn't null). I am using all the newest version of ember and ember data (build from master for ember, from master and basic-adapter branch for emberjs).

Is this not implemented yet or did I miss something ? Since I'm beginning with ember I'm not too confident to submit a pull request, sorry.

Upvotes: 2

Views: 866

Answers (1)

Wojciech Bednarski
Wojciech Bednarski

Reputation: 6373

You need sync object. For example:

App.Post = DS.Model.extend({
        author: DS.attr('string'),
        read: DS.attr('boolen')
    });

    App.Post.sync = {
        query: function (id, process) {
            console.log('find query for Post', arguments);

            $.getJSON('/path/to/API/').then(function (posts) {
                process(posts.map(function (post) {
                    return {
                        author: post.author,
                        read: post.is_read
                    };
                })).load();

                console.log('got posts', posts);
            });
        }
    };

Then associate model with route:

    App.PostRoute = Ember.Route.extend({
    model: function () {
        console.log('Post route');

        return App.Post.find({});
    }
});

Once you visit post route in your app you should be good. {} in find() is important.

Upvotes: 2

Related Questions