DS.Store.load should not overwrite the old information #462

ftokarev opened this Issue Nov 6, 2012 · 3 comments

3 participants


Usecase: server pushes updates to already loaded records. In order to save bandwidth, the server pushes only changed attributes and not the whole record. As a result, we end up with the record with a lot of missing attributes.

As a work-around, I've implemented this:

App.Store = DS.Store.extend({

  load: function (type, id, hash) {
    var id = id+'',
        typeMap = this.typeMapFor(type),
        clientId = typeMap.idToCid[id],
        currentHash, resultHash;

    if (clientId) {
      var record = this.recordCache[clientId];
      if (record) {
        // record is materialized and data is processed
        currentHash = this.getDataOfMaterializedRecord(record);
      } else {
        // record is not materialized yet, its hash is cached
        currentHash = this.clientIdToHash[clientId];
      resultHash = $.extend({}, currentHash, hash);
    } else {
      resultHash = hash;

    this._super(type, id, resultHash);

  getDataOfMaterializedRecord: function (record) {
    var data = record.get("data");
    return $.extend({}, data.attributes, data.belongsTo, data.hasMany);
Ember.js member

Right now we don't support partial loads because there are a number of unresolved issues around this. However, this is something we'd like to support in the future. For now I'll leave this open. @wycats, @tomdale if you want to track this elsewhere it's probably fine to close.

@wycats wycats was assigned Aug 10, 2013
Ember.js member

I'm going to add store.update that contains a partial hash and merges it in to the existing data.

Ember.js member

Done: 97fad9c

@wycats wycats closed this Sep 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment