lib/api-syncRecords.js
function computeDelta(datasetId, clientRecords, serverRecords) {
  var creates = {};
  var updates = {};
  var deletes = {};
  _.each(serverRecords, function(serverRecord, serverRecordUid) {
    var serverRecHash = serverRecord.hash;
    //record is in both client and server
    if (clientRecords[serverRecordUid]) {
      //hash value doesn't match, needs update
      if (clientRecords[serverRecordUid] !== serverRecHash) {
        debug('[%s] Updating client record %s  client hash=%s', datasetId, serverRecordUid, clientRecords[serverRecordUid]);
        updates[serverRecordUid] = serverRecord;
      }
    } else {
      //record is not in the client, needs create
      debug('[%s] Creating client record %s', datasetId, serverRecordUid);
      creates[serverRecordUid] = serverRecord;
    }
  });

  _.each(clientRecords, function(clientRecordHash, clientRecordUid) {
    if (!serverRecords[clientRecordUid]) {
      //the record is in the client but not in the server, need delete
      debug('[%s] Deleting client record %s', datasetId, clientRecordUid);
      deletes[clientRecordUid] = {};
    }
  });

  return {
    create: creates,
    update: updates,
    delete: deletes
  };
}
function computeDelta(datasetId, clientRecords, serverRecords) {
  var creates = {};
  var updates = {};
  var deletes = {};
  _.each(serverRecords, function(serverRecord, serverRecordUid) {
    var serverRecHash = serverRecord.hash;
    //record is in both client and server
    if (clientRecords[serverRecordUid]) {
      //hash value doesn't match, needs update
      if (clientRecords[serverRecordUid] !== serverRecHash) {
        debug('[%s] Updating client record %s  client hash=%s', datasetId, serverRecordUid, clientRecords[serverRecordUid]);
        updates[serverRecordUid] = serverRecord;
      }
    } else {
      //record is not in the client, needs create
      debug('[%s] Creating client record %s', datasetId, serverRecordUid);
      creates[serverRecordUid] = serverRecord;
    }
  });

  _.each(clientRecords, function(clientRecordHash, clientRecordUid) {
    if (!serverRecords[clientRecordUid]) {
      //the record is in the client but not in the server, need delete
      debug('[%s] Deleting client record %s', datasetId, clientRecordUid);
      deletes[clientRecordUid] = {};
    }
  });

  return {
    create: creates,
    update: updates,
    delete: deletes
  };
}
Find out the differences between the clientRecords and the serverRecords
@param {String} datasetId the id of the dataset
@param {Object} clientRecords client records. The key should be the uid of each record, and the value should be the hash of each record
@param {Object} serverRecords server records. The key should be the uid of each record, and the value should contain the `data` and the `hash` of each record
@returns the records that should be created/updated/deleted from the client