-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdatabase.js
More file actions
39 lines (36 loc) · 755 Bytes
/
database.js
File metadata and controls
39 lines (36 loc) · 755 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var pg = require('pg');
var client;
module.exports = {
connect:function(){
var connectString = process.env.DATABASE_URL || "postgres://aubtmwsueljmlo:NgGgFPZeIadarZo81gp-1EKN93@ec2-23-23-199-181.compute-1.amazonaws.com:5432/d80g2kksssndck?ssl=true";
try
{
client = new pg.Client(connectString);
client.connect();
}
catch(e)
{
console.log("Could not connect.");
console.log(e);
}
},
query: function(query, params, callback){
console.log(query);
if (client)
{
try
{
client.query(query,params, callback);
}
catch (e)
{
console.log("Could not connect.");
console.log(e);
}
}
else
{
console.log("Cannot query before connecting.");
}
}
};