<commit_before>'use strict';

const fs        = require('fs');
const path      = require('path');
const Sequelize = require('sequelize');
const basename  = path.basename(module.filename);
const db        = {};
const env       = process.env.NODE_ENV || 'development';
const config    = require('../config/config')[env];
const sequelize = new Sequelize(config.database, config.username, config.password, config);

fs
  .readdirSync(__dirname)
  .filter((file) => {
    return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
  })
  .forEach((file) => {
    let model = sequelize['import'](path.join(__dirname, file));
    db[model.name] = model;
  });

Object.keys(db).forEach((modelName) => {
  if (db[modelName].associate) {
    db[modelName].associate(db);
  }
});

db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;
<commit_msg>Alternative approach for defining models<commit_after>'use strict';

const Sequelize = require('sequelize');
const db        = {};
const env       = process.env.NODE_ENV || 'development';
const config    = require('../config/config')[env];
const sequelize = new Sequelize(config.database, config.username, config.password, config);

// Manual Import Models
db.dns_record   = sequelize.import('./dns_record');
db.Task         = sequelize.import('./task');
db.User         = sequelize.import('./user');
db.vm_distro    = sequelize.import('./vm-distro');
db.vm_template  = sequelize.import('./vm-template');
db.vm_user      = sequelize.import('./vm-user');

Object.keys(db).forEach((modelName) => {
  if (db[modelName].associate) {
    db[modelName].associate(db);
  }
});

db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;

{'fraction_non_alphanumeric': 0.18334297281665704, 'fraction_numerical': 0.001156737998843262, 'mean_word_length': 3.8870056497175143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5647726', 'n_tokens_mistral': 579, 'n_tokens_neox': 562, 'n_words': 107}