Best Practise for integrating existing data(base)


from what i´ve seen, i really like ember.

At the moment i´ve a complex database in which only the child has the parent id, but not the other way around. For example (simplified): Comments:{id:1, name:comment1,post_id:23} and Posts:{id:23, name:post1}.

As you see there is no comments array in posts. So whats the best way to get on from here? I tried adding the ids to the posts and that works, as long there isn´t a null value: Then ember-data requests comments.php which throws “Error: Assertion Failed: The response from a findMany must be an Array, not undefined” in the console. This was done by using the RESTAdapter. No error with FIXTURESAtapter.

So i tried it the other way starting with the comments to iterate JSBIN But that doesn´t work at all.

So bevor i try to find the error, i would be grateful to know what way i should be going.

Cause i´m a ember starter: if anyone knows an example or JSBIN it would be nice.



You can look at returning a “links” record within post that has a link to a endpoint that lists the comments for that post.

A possible example would be post: { id: 5 links: { comments: “/posts/5/comments” } }

This way you do not have to poll the comment id’s every time, but now ED knows where to fetch the relationship.

Also you will probably need to mark all the relationships with the async option in your model description.

thank you for taking the time to answer.

Can you or anybody else think of a way where i don´t have to change the parent table or why ember-data is looking for a null value (comments.php?id=) if the array with the comments id is emtpy ?