code: function loadModels(app, datasource, src, cb = null) {
    const ds = app.dataSources[datasource];
    let promises = [], modelsNames = [];
  
    let files = fs.readdirSync(src);
    if (files) {
      files.forEach(file => {
        // load model for all model json files
        if (file.endsWith('.json')) {
          promises.push( new Promise((resolve, reject) => {
            fs.readFile(`${src}/${file}`, 'utf8', (fileErr, data) => {
              if (fileErr) app.error(`Failed reading %s because: %s`, file, fileErr);
              else {
                let mJson = JSON.parse(data);
                let model = loopback.createModel(mJson);
                app.model(model, {dataSource: datasource});
                modelsNames.push(mJson.name);
                resolve();
              }
            });
          }));
        }
      });
    }
  
    Promise.all(promises).then(() => {
      // process addl model js
      if (files) {
        files.forEach(file => {
          if (file.endsWith('.js')) {
            require(`${src}/${file}`)(app);
          }
        });
        /**
         * NOTE: UNCOMMENT TO UPDATE DB ON PRODUCTION ALTHOUGH THAT SHOULD BE
         * AVOIDED BECAUSE IT RECREATE TABLE STRUCTURE AND REMOVES INDEXES, while
         * TRYING TO REBUILD STRUCTURE/INDEX IT CAN LEAVE SOME OUT ON LARGE DB AND
         * CREATE OPTIMIZATION NIGHTMARE
         */
        //if ('build' === process.env.WORK && !_.isEmpty(modelsNames)) {
        if ('development' === process.env.NODE_ENV && !_.isEmpty(modelsNames)) {
          ds.autoupdate(modelsNames);
        }
      }
      if (cb) cb();
    });
  }
docs: for loading models