-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdb.js
41 lines (34 loc) · 1.14 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const mongoose = require('./backend/node_modules/mongoose');
//below needed to get hints/intellisense for mongoose commands, above is needed for actual mongoose operation
//const mongoose = require('mongoose');
/* SEMI NEW */
/*const url = `mongodb+srv://gabrielchuv:[email protected]/myFirstDatabase?retryWrites=true&w=majority`;*/
/* NEW NEW */
/*const url = process.env.MONGODB_URI;*/
/* NEW */
/*const options={
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true
}*/
const Fooditem = require('./backend/database/models/fooditem');
const Bin = require('./backend/database/models/bin');
var collectionArray = new Array();
/* OLD */
const {
MONGO_USERNAME,
MONGO_PASSWORD,
MONGO_HOSTNAME,
MONGO_PORT,
MONGO_DB
} = process.env;
/* OLD */
const options = {
useNewUrlParser: true,
useUnifiedTopology: true,
};
/* OLD */
const url = `mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOSTNAME}:${MONGO_PORT}/${MONGO_DB}?authSource=admin`;
mongoose.connect(url, options).
then(() => { console.log('MongoDB is connected') })
.catch((err) => { console.log(err) });