Skip to content

Commit

Permalink
build database and connection
Browse files Browse the repository at this point in the history
  • Loading branch information
ismail2009 committed Jan 15, 2018
1 parent 5e3a759 commit e9fa13b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions database/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

const connect = require('./dbConnection');
const fs = require('fs');
const path = require('path');

const sql = fs.readFileSync(path.join(__dirname, '/build.sql'));
connect.query(sql, (err, res) => {
if (err) {
console.log(err);
} else {
console.log(res);
}
});
Empty file added database/build.sql
Empty file.
9 changes: 9 additions & 0 deletions database/dbConnection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { Pool } = require('pg');
require('env2')('config.env');

if (!process.env.DB_URL) {
throw new Error('DATABASE_URL is undefined. ');
}
module.exports = new Pool({
connectionString: process.env.DB_URL,
});
Empty file added database/queries/instruction.js
Empty file.
Empty file added database/queries/solution.js
Empty file.
Empty file added database/test/database.js
Empty file.

0 comments on commit e9fa13b

Please sign in to comment.