Ember.js 可选的belongsTo关系未推送到存储

Ember.js 可选的belongsTo关系未推送到存储,ember.js,ember-data,Ember.js,Ember Data,我遇到了一个问题,可选的belongsTo关系没有正确地推送到存储区。在我的余烬应用程序中,我有两个可选模型之间的关系。例如,想象一下: App.User = DS.Model.extend({ profile: DS.hasMany('profile', {'async': true}) }); App.Profile = DS.Model.extend({ user: DS.belongsTo('user', {'async': true}) }); 其中“配置文件”模型中的“用

我遇到了一个问题,可选的belongsTo关系没有正确地推送到存储区。在我的余烬应用程序中,我有两个可选模型之间的关系。例如,想象一下:

App.User = DS.Model.extend({
  profile: DS.hasMany('profile', {'async': true})
});

App.Profile = DS.Model.extend({
  user: DS.belongsTo('user', {'async': true})
});
其中“配置文件”模型中的“用户”字段可以为空。当它为空时,序列化程序应返回

....
relationships: {
  user: null
}
...
在规范化负载中,至少如果我正确解释了JSON-API标准()。问题是,这似乎没有被推到商店。我可以通过

  • 从后端加载关系“user”设置为null的“Profile”记录
  • 将客户端上该特定记录的“用户”值更改为非空值
  • 从后端重新加载记录
  • 在这些步骤之后,“Profile”记录上的“user”字段仍然保持其错误的非空值


    这是预期行为还是错误?如果这是预期的行为,我应该如何跟踪这些更改以保持数据完整性?

    再次查看JSON-API后,似乎我对它的解释是错误的。标准化的有效负载应该是

    ...
    relationships: {
      user: {
        data: null
      }
    }
    ...
    

    这帮我解决了问题

    再看一眼JSON-API,我似乎把它解释错了。标准化的有效负载应该是

    ...
    relationships: {
      user: {
        data: null
      }
    }
    ...
    
    这帮我解决了问题