Is there a way to add another option for belongsTo function in DS.Model?


#1

I have a DS.Model that has the following relationships:

var myModel = DS.Model.extend({
  anotherModel: DS.attr('anotherModel', { async: false })
});

The problem I’m having is that there are times the server returns the attribute anotherModel with an empty string. In other words, the server is giving me this:

{myModel: {anotherModel: ""}}

When I get that from the server, ember is adding a bad object to the data store of anotherModel. This is a huge problem for me, because my web app has a web socket so there will be many instances where the server will return a JSON like the one above, and that causes the data store for anotherModel to continuously grow. After running my web app for 5 mins, I’d have over 1000 records in the data store for anotherModel – consisting mostly of bad data.

Can someone please offer me some insight?