-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
32 lines (28 loc) · 703 Bytes
/
db.js
File metadata and controls
32 lines (28 loc) · 703 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
import pkg from "pg";
const { Pool } = pkg;
const pool = new Pool({
user: "postgres",
host: "localhost",
database: "Ngo_website",
password: "Suraj@#6708",
port: 5432,
});
// Method to connect to the database
const connect = async () => {
try {
await pool.connect();
console.log("Connected to the database");
} catch (err) {
console.error("Error connecting to the database:", err);
}
};
// Method to disconnect from the database
const disconnect = async () => {
try {
await pool.end();
console.log("Disconnected from the database");
} catch (err) {
console.error("Error disconnecting from the database:", err);
}
};
export { pool, connect, disconnect };