Skip to content


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

ftokarev opened this Issue · 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);

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

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


Done: 97fad9c

@wycats wycats closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.