lib/services/models.js
function get(model, renderModel, executeRender, uri, locals) { /* eslint max-params: ["error", 5] */
  var promise;

  if (executeRender) {
    const startTime = process.hrtime(),
      timeoutLimit = TIMEOUT_CONSTANT * TIMEOUT_GET_COEFFICIENT;

    promise = bluebird.try(() => {
      return db.get(uri)
        .then(upgrade.init(uri, locals)) // Run an upgrade!
        .then(data => model.render(uri, data, locals));
    }).tap(result => {
      const ms = timer.getMillisecondsSince(startTime);

      if (!_.isObject(result)) {
        throw new Error(`Component model must return object, not ${typeof result}: ${uri}`);
      }

      if (ms > timeoutLimit * 0.5) {
        log('warn', `slow get ${uri} ${ms}ms`);
      }
    }).timeout(timeoutLimit, `Model GET exceeded ${timeoutLimit}ms: ${uri}`);

  } else {
    promise = db.get(uri).then(upgrade.init(uri, locals)); // Run an upgrade!
  }

  if (renderModel && _.isFunction(renderModel)) {
    promise = promise.then(data => renderModel(uri, data, locals));
  }

  return promise.then(data => {
    if (!_.isObject(data)) {
      throw new Error(`Client: Invalid data type for component at ${uri} of ${typeof data}`);
    }

    return data;
  });
}
function get(model, renderModel, executeRender, uri, locals) { /* eslint max-params: ["error", 5] */
  var promise;

  if (executeRender) {
    const startTime = process.hrtime(),
      timeoutLimit = TIMEOUT_CONSTANT * TIMEOUT_GET_COEFFICIENT;

    promise = bluebird.try(() => {
      return db.get(uri)
        .then(upgrade.init(uri, locals)) // Run an upgrade!
        .then(data => model.render(uri, data, locals));
    }).tap(result => {
      const ms = timer.getMillisecondsSince(startTime);

      if (!_.isObject(result)) {
        throw new Error(`Component model must return object, not ${typeof result}: ${uri}`);
      }

      if (ms > timeoutLimit * 0.5) {
        log('warn', `slow get ${uri} ${ms}ms`);
      }
    }).timeout(timeoutLimit, `Model GET exceeded ${timeoutLimit}ms: ${uri}`);

  } else {
    promise = db.get(uri).then(upgrade.init(uri, locals)); // Run an upgrade!
  }

  if (renderModel && _.isFunction(renderModel)) {
    promise = promise.then(data => renderModel(uri, data, locals));
  }

  return promise.then(data => {
    if (!_.isObject(data)) {
      throw new Error(`Client: Invalid data type for component at ${uri} of ${typeof data}`);
    }

    return data;
  });
}
function get ( model , renderModel , executeRender , uri , locals ) { /* eslint max-params: ["error", 5] */ var promise ; if ( executeRender ) { const startTime = process . hrtime ( ) , timeoutLimit = TIMEOUT_CONSTANT * TIMEOUT_GET_COEFFICIENT ; promise = bluebird . try ( ( ) => { return db . get ( uri ) . then ( upgrade . init ( uri , locals ) ) // Run an upgrade! . then ( data => model . render ( uri , data , locals ) ) ; } ) . tap ( result => { const ms = timer . getMillisecondsSince ( startTime ) ; if ( ! _ . isObject ( result ) ) { throw new Error ( ` ${ typeof result } ${ uri } ` ) ; } if ( ms > timeoutLimit * 0.5 ) { log ( 'warn' , ` ${ uri } ${ ms } ` ) ; } } ) . timeout ( timeoutLimit , ` ${ timeoutLimit } ${ uri } ` ) ; } else { promise = db . get ( uri ) . then ( upgrade . init ( uri , locals ) ) ; // Run an upgrade! } if ( renderModel && _ . isFunction ( renderModel ) ) { promise = promise . then ( data => renderModel ( uri , data , locals ) ) ; } return promise . then ( data => { if ( ! _ . isObject ( data ) ) { throw new Error ( ` ${ uri } ${ typeof data } ` ) ; } return data ; } ) ; }
Execute the get function of a model.js file
for either a component or a layout

@param {Object} model
@param {Object} renderModel
@param {Boolean} executeRender
@param {String} uri
@param {Object} locals
@returns {Promise}
Execute the get function of a model . js file for either a component or a layout