Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4829

How do I handle broken belongTo relationships?

$
0
0

@xwingz wrote:

Due to a bug in our API server, Ember Data is creating records that doesn't exist. It's a bit difficult to explain, so I'll provide an example. Let's say we have these models.

models/foo.js

export default DS.Model.extend({
  bar: DS.belongsTo('bar', { async: false });
});

models/bar.js

export default DS.Model.extend({
  someAttr: DS.attr()
});

When we do a DS.store.findAll on foo and bar, the API would (occassionally) return something like this: http://codebeautify.org/jsonviewer/cb54318b

This causes Ember Data to create a foo record with ID of "foo2", which has all of its attributes being undefined. Is there a way to let Ember Data know that "foo2" does not exist, and prevent the creation of a phantom record?

Thanks.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4829

Trending Articles