"use strict";

var fs        = require("fs");
var path      = require("path");
var Sequelize = require("sequelize");
var env       = /*process.env.NODE_ENV || */"production";
var config    = require(path.join(__dirname, '..', 'config', 'config.json'))[env];
var sequelize = new Sequelize(config.database, config.username, config.password, config);
var db        = {};

fs
  .readdirSync(__dirname)
  .filter(function(file) {
    return (file.indexOf(".") !== 0) && (file !== "index.js");
  })
  .forEach(function(file) {
    var model = sequelize.import(path.join(__dirname, file));
    db[model.name] = model;
  });

Object.keys(db).forEach(function(modelName) {
  if ("associate" in db[modelName]) {
    db[modelName].associate(db);
  }
});

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

module.exports = db;
/* play.js
"use strict";

module.exports = function(sequelize, DataTypes) {
  var Play = sequelize.define("Play", {
  }, {
    comment : "Play table connect user A and room B so it means  A joined B.",
    classMethods: {
      associate: function(models) {
        Play.belongsTo(models.User, {foreignkey: 'username'});
        Play.belongsTo(models.Room, {foreignkey: 'roomid'});
      }
    }
  });

  return Play;
};
*/

"use strict";

var fs        = require("fs");
var path      = require("path");
var Sequelize = require("sequelize");
var env       = process.env.NODE_ENV || "production";
var config    = require(path.join(__dirname, '..', 'config', 'config.json'))[env];
var sequelize = new Sequelize(config.database, config.username, config.password, config);
var db        = {};

fs
  .readdirSync(__dirname)
  .filter(function(file) {
    return (file.indexOf(".") !== 0) && (file !== "index.js");
  })
  .forEach(function(file) {
    var model = sequelize.import(path.join(__dirname, file));
    db[model.name] = model;
  });

Object.keys(db).forEach(function(modelName) {
  if ("associate" in db[modelName]) {
    db[modelName].associate(db);
  }
});

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

module.exports = db;
/* play.js
"use strict";

module.exports = function(sequelize, DataTypes) {
  var Play = sequelize.define("Play", {
  }, {
    comment : "Play table connect user A and room B so it means  A joined B.",
    classMethods: {
      associate: function(models) {
        Play.belongsTo(models.User, {foreignkey: 'username'});
        Play.belongsTo(models.Room, {foreignkey: 'roomid'});
      }
    }
  });

  return Play;
};
*/

Remove comment because environment variable should be applied.
Remove comment because environment variable should be applied.
