Created
April 25, 2016 12:21
-
-
Save giacomorebonato/579ea349417bdd3c03829457619ac6b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path') | |
module.exports = { | |
'config': path.resolve('server', 'config', 'database.json'), | |
'migrations-path': path.resolve('server', 'migrations'), | |
'models-path': path.resolve('server', 'models'), | |
'seeders-path': path.resolve('server', 'seeders'), | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
import fs from 'fs' | |
import path from 'path' | |
import Sequelize from 'sequelize' | |
var basename = path.basename(module.filename) | |
var env = process.env.NODE_ENV || 'development' | |
var config = require(path.join(__dirname, '/../config/database.json'))[env] | |
var db = {} | |
var sequelize | |
if (config.use_env_variable) { | |
sequelize = new Sequelize(process.env[config.use_env_variable]); | |
} else { | |
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) => { | |
var 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 | |
export default db |
@Mr-emeka dude, that's not an extension, files started witd dot is hidden in linux
@v-vashchenko LOL thanks,this post is a year plus now.i know that know thanks alot.
I wasn't following this thread! Thanks for answering!
didn't find another example of .sequelizerc, thank you very much
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my project the extension .sequelizerc isn't recognised. what do i do?