<commit_before>/**
 * Creates database representations of the Model types.
 *
 * @public
 */
exports.createModels = function () {
  sails.log('sails-permissions: syncing waterline models');

  var models = _.compact(_.map(sails.controllers, function (controller, name) {
    var modelName = controller._config ? controller._config.model : name
      , model = sails.models[modelName]
    ;
    return model && model.globalId && model.identity && {
      name: model.globalId,
      identity: model.identity,
      attributes: _.omit(model.attributes, _.functions(model.attributes))
    };
  }));

  return Promise.map(models, function (model) {
    return Model.findOrCreate({ name: model.name }, model);
  });
};<commit_msg>Better (safer) way of doing the above, avoids the case where other config overrides are provided but not model<commit_after>/**
 * Creates database representations of the Model types.
 *
 * @public
 */
exports.createModels = function () {
  sails.log('sails-permissions: syncing waterline models');

  var models = _.compact(_.map(sails.controllers, function (controller, name) {
    var conf = controller._config
      , modelName = conf && conf.model && conf.model.name
      , model = sails.models[modelName || name]
    ;
    return model && model.globalId && model.identity && {
      name: model.globalId,
      identity: model.identity,
      attributes: _.omit(model.attributes, _.functions(model.attributes))
    };
  }));

  return Promise.map(models, function (model) {
    return Model.findOrCreate({ name: model.name }, model);
  });
};
{'fraction_non_alphanumeric': 0.13341804320203304, 'fraction_numerical': 0.0, 'mean_word_length': 3.578488372093023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3591674', 'n_tokens_mistral': 452, 'n_tokens_neox': 441, 'n_words': 117}