elastic-harvester.js
function unexpandSubentity(subEntity) {
  if (_.isArray(subEntity)) {
    _.each(subEntity, (entity, index) => {
      subEntity[index] = unexpandSubentity(entity);
    });
  } else {
    _.each(subEntity, (val, propertyName) => {
      if (_.isObject(val) && val.id) {
        subEntity.links = subEntity.links || {};
        subEntity.links[propertyName] = val.id;
        delete subEntity[propertyName];
      }
    });
  }

  return subEntity;
}
function unexpandSubentity(subEntity) {
  if (_.isArray(subEntity)) {
    _.each(subEntity, (entity, index) => {
      subEntity[index] = unexpandSubentity(entity);
    });
  } else {
    _.each(subEntity, (val, propertyName) => {
      if (_.isObject(val) && val.id) {
        subEntity.links = subEntity.links || {};
        subEntity.links[propertyName] = val.id;
        delete subEntity[propertyName];
      }
    });
  }

  return subEntity;
}
function unexpandSubentity ( subEntity ) { if ( _ . isArray ( subEntity ) ) { _ . each ( subEntity , ( entity , index ) => { subEntity [ index ] = unexpandSubentity ( entity ) ; } ) ; } else { _ . each ( subEntity , ( val , propertyName ) => { if ( _ . isObject ( val ) && val . id ) { subEntity . links = subEntity . links || { } ; subEntity . links [ propertyName ] = val . id ; delete subEntity [ propertyName ] ; } } ) ; } return subEntity ; }
A sub-entity is a linked object returned by es as part of the source graph. They are expanded differently from
primary entities, and must be unexpanded differently as well.
A sub - entity is a linked object returned by es as part of the source graph . They are expanded differently from primary entities and must be unexpanded differently as well .