-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from GSG-K3/intializedatabase
intilaize database #19
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const dbConnection = require("./connection.js"); | ||
|
||
|
||
const dbBuild = () => { | ||
const sqlPath = readFileSync (join(__dirname, "build.sql")).toString(); | ||
return dbConnection.query(sql,( err,res)=>{ | ||
if(err) throw new Error('error build.js'); | ||
else console.log('build sucsess'); | ||
|
||
}); | ||
}; | ||
|
||
|
||
|
||
module.exports = {dbBuild}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require("env2")("./config.env"); | ||
const { Pool } = require("pg"); | ||
const url = ''; | ||
|
||
let connectionString = process.env.DB_URL; | ||
|
||
if (process.env.NODE_ENV === "test") { | ||
connectionString = process.env.TEST_DB_URL; | ||
} | ||
if (!connectionString) { | ||
throw new Error("please set a DB_URL env variable"); | ||
|
||
} | ||
const options = { | ||
connectionString: url, | ||
sll: true | ||
}; | ||
|
||
module.exports = new Pool(options); |