{"size": 688, "ext": "js", "max_stars_repo_path": "io-lbapp/server/scripts/install/populate.js", "max_stars_repo_name": "jledun/io-demo", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "io-lbapp/server/scripts/install/populate.js", "max_issues_repo_name": "jledun/io-demo", "max_issues_repo_issues_event_min_datetime": "2020-07-20T16:31:19.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T04:34:24.000Z", "max_forks_repo_path": "io-lbapp/server/scripts/install/populate.js", "max_forks_repo_name": "jledun/io-applications", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 7, "max_forks_count": null, "avg_line_length": 20.8484848485, "max_line_length": 83, "alphanum_fraction": 0.574127907}
'use strict';

let modelsToPopulate = [
  {
    modelName: 'UomCateg',
    filename: 'uom-categ'
  },
  {
    modelName: 'EventType',
    filename: 'event-type'
  },
  {
    modelName: 'Uom',
    filename: 'uom'
  }
]

let populate = ( app, name, data ) => {
  // create base datas for units
  let model = app.models[ name ];
  model.create( data, ( err ) => {
    if ( err ) {
      console.log( `Something went wrong while working on ${name} datas` );
      console.log( err );
      process.exit(-1);
    }
  });
};

let app = require('../../server');
modelsToPopulate.forEach( ( toPopulate ) => {
  populate( app, toPopulate.modelName, require( `./${toPopulate.filename}.json` ));
});