-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
27 lines (22 loc) · 1.08 KB
/
db.js
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
// This file is our opening or starting file.
// This standalone file is set so that we couldconnect to our database.
const dotenv = require('dotenv')
dotenv.config() // so we can use the config fie dotenv...
const {MongoClient} = require('mongodb')
const client = new MongoClient(process.env.CONNECTIONSTRING)
// connectionString
//const connectionString = 'mongodb+srv://complexAppHehe:WOHENshousi1984@cluster0.rqdp8.mongodb.net/complexApp?authSource=admin&replicaSet=atlas-ignr3c-shard-0&readPreference=primary&appname=MongoDB%20Compass&ssl=true'
async function start() {
await client.connect()
module.exports = client
const app = require('./app')
app.listen(process.env.PORT)
//app.listen(3000)
}
start()/*
mongodb.connect(process.env.CONNECTIONSTRING, {useNewUrlParser: true, useUnifiedTopology: true}, function(err, client) {
module.exports = client
const app = require('./app')
app.listen(process.env.PORT)// It works perfectly well for our local environment, but we might need to push it online... we might need a different value here...
//e.g. heroku.
})*/