app/Framework/ResourceController.js
/**
   *  Format a resource from a data model object, adds href to the data model
   *  based on the routes resourceSchema or routeParams
   *
   *  @param {object} dataModel
   *  @param {string} routeName used for href
   *  @param {object} routeParams (optional) Params used to generate href if not
   *                              provided then will attempt to use primary key
   *                              from the routeNames resourceSchema.
   *                              
   *  @return {object}
   */
Format a resource from a data model object, adds href to the data model
based on the routes resourceSchema or routeParams

@param {object} dataModel
@param {string} routeName used for href
@param {object} routeParams (optional) Params used to generate href if not
provided then will attempt to use primary key
from the routeNames resourceSchema.

@return {object}
Format a resource from a data model object adds href to the data model based on the routes resourceSchema or routeParams @param { object } dataModel @param { string } routeName used for href @param { object } routeParams ( optional ) Params used to generate href if not provided then will attempt to use primary key from the routeNames resourceSchema . @return { object }
formatResource(dataModel, routeName, routeParams) {
    if(routeParams === undefined) {
      let route = this.getRouteFromName(routeName);
      if(route !== undefined) {
        let primaryFields = route.resourceSchema.filter((field) => field.attributes.indexOf('primary') > -1);
        if(primaryFields.length > 0) {
          let key = primaryFields.shift().key;
          routeParams = {};
          routeParams[key] = dataModel[key] || ':' + key;
        }
      }
    }
    let id = dataModel.id !== undefined ? dataModel.id : ':id';
    routeParams = routeParams || {id: id};
    dataModel.href = this.generateUrl(routeName, routeParams);
    return dataModel;
  }
formatResource ( dataModel , routeName , routeParams ) { if ( routeParams === undefined ) { let route = this . getRouteFromName ( routeName ) ; if ( route !== undefined ) { let primaryFields = route . resourceSchema . filter ( ( field ) => field . attributes . indexOf ( 'primary' ) > - 1 ) ; if ( primaryFields . length > 0 ) { let key = primaryFields . shift ( ) . key ; routeParams = { } ; routeParams [ key ] = dataModel [ key ] || ':' + key ; } } } let id = dataModel . id !== undefined ? dataModel . id : ':id' ; routeParams = routeParams || { id : id } ; dataModel . href = this . generateUrl ( routeName , routeParams ) ; return dataModel ; }
Format a resource from a data model object, adds href to the data model
  based on the routes resourceSchema or routeParams
Format a resource from a data model object adds href to the data model based on the routes resourceSchema or routeParams