-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
43 lines (30 loc) · 1.17 KB
/
db.js
File metadata and controls
43 lines (30 loc) · 1.17 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const { Pool } = require('pg')
const connectionString = "postgresql://postgres:m2awBeVZZ4sbcIOlF1Pq@containers-us-west-178.railway.app:7639/railway"
const connectionLocal = {
user: 'postgres',
host: 'localhost',
database: 'assembly-backend',
password: ''
}
// this line of code is for heroku or netify to run the backend from a third party host
const connectionProduction = {
connectionString: connectionString,
ssl: {rejectUnauthorized: false}
}
const pool = new Pool(process.env.NODE_ENV === 'production' ? connectionProduction : connectionLocal)
module.exports = pool
// pool is an object given to us by the pg library,
// that allows us to run query command and returns a promise to give us that data.
// const { Pool } = require('pg')
// const connectionString = 'postgresql://postgres:f1ynjwcZwvCVSbPqlFAH@containers-us-west-32.railway.app:7290/railway'
// const developmentPool = new Pool(
// {
// database: 'todo4',
// user: 'postgres',
// password: ''
// })
// const productionPool = new Pool({
// connectionString
// })
// const pool = (process.env.NODE_ENV === "production" ? productionPool: developmentPool)
// module.exports = pool