Lunching for groups.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
844 B

11 years ago
// Taken directly from Sequelize documentation
var fs = require('fs'),
path = require('path'),
Sequelize = require('sequelize-sqlite').sequelize,
sqlite = require('sequelize-sqlite').sqlite,
lodash = require('lodash'),
db = {};
var sequelize = new Sequelize('database', 'username', null, {
dialect: 'sqlite',
storage: './luncho.sq'
});
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);
}
});
module.exports = lodash.extend({
sequelize: sequelize,
Sequelize: Sequelize
}, db);