-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
22 lines (18 loc) · 640 Bytes
/
Copy pathdb.js
File metadata and controls
22 lines (18 loc) · 640 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const mongoose = require("mongoose");
// Config from Environment variables
let db = process.env.APP_DB;
// Connect to MongoDB
// mongoose
// .connect(db, { useNewUrlParser: true, useUnifiedTopology: true })
// .then(() => console.log("MongoDB successfully connected"))
// .catch(err => console.log(err));
mongoose.connect(db, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false
});
mongoose.connection.on('error', console.error.bind(console, 'connection error'));
mongoose.connection.once('open', function() {
console.log('MongoDB successfully connected');
});
module.exports = mongoose.connection;