forked from abhshkdz/HackFlowy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorm.js
More file actions
26 lines (23 loc) · 709 Bytes
/
Copy pathorm.js
File metadata and controls
26 lines (23 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var Sequelize = require('sequelize');
/* http://sequelizejs.com/articles/heroku */
var parseUrl = function(url) {
var match = url.match(/([\w]+):\/\/([^:]+):([^@]+)@([^:]+):(\d+)\/(.+)/);
db = {
database : match[6],
username : match[2],
password : match[3],
options : {
port : match[5],
host : match[4],
dialect : match[1],
}
}
return db;
}
module.exports = {
configure: function(db) {
db.url = db.use_env_variable ? process.env[db.use_env_variable] : null;
db = db.url ? parseUrl(db.url) : db;
return new Sequelize(db.database, db.username, db.password, db.options);
}
}