function initializeFieldsFromAdapter(adapterResult) {
  if (typeof adapterResult != 'object')
    return;

  let responsibleAdapter = adapters.getAdapterForSource(adapterResult.sourceID);
  let supportedFields = responsibleAdapter.getSupportedFields();
  for (let field in adapterResult.data) {
    if (supportedFields.includes(field)) {
      this[field] = adapterResult.data[field];
      if (typeof this.sync != 'object')
        this.sync = {};
      this.sync[field] = {
        active: true,
        source: adapterResult.sourceID,
        updated: new Date()
      };
    }
  }
}
/**
 * Initialize field values from the lookup result of an adapter. Each adapter
 * has a whitelist of supported fields which we check against before assigning
 * values to the thing instance.
 *
 * This function does not save and can therefore run synchronously.
 * It resets all sync settings (whether a sync for a given field is active or
 * not), so it should only be invoked on new Thing objects.
 *
 * Silently ignores empty results.
 *
 * @param {Object} adapterResult
 *  the result from any backend adapter
 * @param {Object} adapterResult.data
 *  data for this result
 * @param {String} adapterResult.sourceID
 *  canonical source identifier
 * @throws
 *  on malformed adapterResult object
 * @instance
 * @memberof Thing
 */
Initialize field values from the lookup result of an adapter. Each adapter
has a whitelist of supported fields which we check against before assigning
values to the thing instance.

This function does not save and can therefore run synchronously.
It resets all sync settings (whether a sync for a given field is active or
not), so it should only be invoked on new Thing objects.

Silently ignores empty results.


Initialize field values from the lookup result of an adapter . Each adapter has a whitelist of supported fields which we check against before assigning values to the thing instance . This function does not save and can therefore run synchronously . It resets all sync settings ( whether a sync for a given field is active or not ) so it should only be invoked on new Thing objects . Silently ignores empty results .
function initializeFieldsFromAdapter(adapterResult) {
  if (typeof adapterResult != 'object')
    return;
  let responsibleAdapter = adapters.getAdapterForSource(adapterResult.sourceID);
  let supportedFields = responsibleAdapter.getSupportedFields();
  for (let field in adapterResult.data) {
    if (supportedFields.includes(field)) {
      this[field] = adapterResult.data[field];
      if (typeof this.sync != 'object')
        this.sync = {};
      this.sync[field] = {
        active: true,
        source: adapterResult.sourceID,
        updated: new Date()
      };
    }
  }
}
function initializeFieldsFromAdapter ( adapterResult ) { if ( typeof adapterResult != 'object' ) return ; let responsibleAdapter = adapters . getAdapterForSource ( adapterResult . sourceID ) ; let supportedFields = responsibleAdapter . getSupportedFields ( ) ; for ( let field in adapterResult . data ) { if ( supportedFields . includes ( field ) ) { this [ field ] = adapterResult . data [ field ] ; if ( typeof this . sync != 'object' ) this . sync = { } ; this . sync [ field ] = { active : true , source : adapterResult . sourceID , updated : new Date ( ) } ; } } }
Initialize field values from the lookup result of an adapter.
Initialize field values from the lookup result of an adapter .