Skip to content

Commit f701ca1

Browse files
authored
Merge pull request #17 from oslabs-beta/new_cleanUp
New clean up
2 parents 98a9450 + 919124e commit f701ca1

File tree

9 files changed

+632
-853
lines changed

9 files changed

+632
-853
lines changed

electron/databases/mongo.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import mongoose from 'mongoose';
22
// import { MongoError } from 'mongodb';
3+
const testURL = '';
34
// Mongoose connection wrapped in function that takes the index of the selected database as the parameter. This index is used to target the correct database for querying.
45
const connectMongoose = async (i:number, URI: string) => {
56
try {
67
await mongoose.connection.close();
7-
const db = await mongoose.connect(URI);
8-
8+
const db = await mongoose.connect(URI)
99
return db;
1010
} catch (err) {
1111
console.log(`${__dirname}/mongo.ts/connectMongoose: ${err}`);
1212
}
1313
};
1414

15+
// const connectMongoose = async (i: number, URI: string) => {
16+
// try {
17+
// const db2 = mongoose.createConnection(testURL);
18+
// console.log('connection to user provided db established..');
19+
// return db2;
20+
// } catch (error) {
21+
// console.log('Error connecting to second db... ', error);
22+
// }
23+
// }
24+
1525
export default connectMongoose;

electron/databases/postgres.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
import { Pool } from 'pg';
22
// SQL connection wrapped in function that takes the index of the selected database as the parameter. This index is used to target the correct database for querying.
3-
const connectSQL = (i: number, URI: string) => {
4-
return new Pool({
5-
connectionString: URI,
6-
});
3+
const connectSQL = async (i: number, URI: string) => {
4+
try {
5+
const pool= new Pool({
6+
connectionString: URI,
7+
})
8+
const client = await pool.connect();
9+
client.release()
10+
console.log('connected to sql')
11+
return pool;
12+
} catch (err) {
13+
console.log('Error connecting to SQL')
14+
return null;
15+
}
716
};
817

918
export default connectSQL;

0 commit comments

Comments
 (0)