summaryrefslogtreecommitdiff
path: root/server/db.js
blob: d921243955b916b526182557a8dce35ced461b65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var Sequelize = require("sequelize"),
  config = require("../config.json"),
  pg = require('pg');

var db = module.exports = {}

var DATABASE_URL = process.env.DATABASE_URL || ('postgres://postgres:postgres@localhost:5432/' + config.name)

var match = DATABASE_URL.match(/postgres:\/\/([^:]+):([^@]+)@([^:]+):(\d+)\/(.+)/)

db.sequelize = new Sequelize(match[5], match[1], match[2], {
  dialect: 'postgres',
  protocol: 'postgres',
	port:     match[4],
	host:     match[3],
	logging:  true //false
})