-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbutil.js
More file actions
29 lines (22 loc) · 717 Bytes
/
dbutil.js
File metadata and controls
29 lines (22 loc) · 717 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
import mongoose from 'mongoose';
import dotenv from 'dotenv';
import tenantSchema from './models/tenantModel.js';
dotenv.config();
let log = console.log;
let clientOption = {
wtimeoutMS : 30000,
// reconnectTries : 30000,
maxPoolSize : 50,
keepAlive : true,
useNewUrlParser : true,
autoIndex : false
};
export let initDbConnection = () => {
let db = mongoose.createConnection(process.env.MONGODB_URI, clientOption);
db.on("error", (error) => log("Mongodb Connection Error>> : ", error));
db.once("open", () => log("Client MongoDB connection ok!"));
// require("./models/tenantModel.js");
tenantSchema;
return db;
};
export let dbInit = initDbConnection()